closest


Description:

public uint closest (uint num)

Gets the smallest prime number from a built-in array of primes which is larger than num.

This is used within GLib to calculate the optimum size of a GenericSet.

The built-in array of primes ranges from 11 to 13845163 such that each prime is approximately 1.5-2 times the previous prime.

Example: Get the closest prime number:

public static int main (string[] args) {
// Output: ``11``
uint prime = SpacedPrimes.closest (10);
print ("%u\n", prime);
return 0;
}

valac --pkg glib-2.0 GLib.SpacedPrimes.closest.vala

Parameters:

num

a uint

Returns:

the smallest prime number from a built-in array of primes which is larger than num


Namespace: GLib.SpacedPrimes
Package: glib-2.0