gmp_lib.mpz_nextprime Method

GMP Native Interface for .NET

gmp_libmpz_nextprime Method
Set rop to the next prime greater than op.

Namespace:  Math.Gmp.Native
Assembly:  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public static void mpz_nextprime(
	mpz_t rop,
	mpz_t op
)
Public Shared Sub mpz_nextprime ( 
	rop As mpz_t,
	op As mpz_t
)
public:
static void mpz_nextprime(
	mpz_t^ rop, 
	mpz_t^ op
)
static member mpz_nextprime : 
        rop : mpz_t * 
        op : mpz_t -> unit 

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result prime integer.
op
Type: Math.Gmp.Nativempz_t
The operand integer.
Remarks

This function uses a probabilistic algorithm to identify primes. For practical purposes it’s adequate, the chance of a composite passing will be extremely small.

Examples
// Create, initialize, and set the value of n to 12.
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_ui(op, 12U);

// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Set rop to the next following op.
gmp_lib.mpz_nextprime(rop, op);

// Assert that rop is 13.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 13);

// Release unmanaged memory allocated for rop and op.
gmp_lib.mpz_clears(rop, op, null);
' Create, initialize, and set the value of n to 12.
Dim op As New mpz_t()
gmp_lib.mpz_init_set_ui(op, 12UI)

' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Set rop to the next following op.
gmp_lib.mpz_nextprime(rop, op)

' Assert that rop is 13.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 13)

' Release unmanaged memory allocated for rop and op.
gmp_lib.mpz_clears(rop, op, Nothing)

No code example is currently available or this language may not be supported.

No code example is currently available or this language may not be supported.

See Also