PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

gmp_random> <gmp_powm
Last updated: Fri, 10 Oct 2008

view this page in

gmp_prob_prime

(PHP 4 >= 4.0.4, PHP 5)

gmp_prob_primeCheck if number is "probably prime"

Beschreibung

int gmp_prob_prime ( resource $a [, int $reps ] )

The function uses Miller-Rabin's probabilistic test to check if a number is a prime.

Parameter-Liste

a

The number being checked as a prime.

Dies kann entweder eine resource für einen GMP Wert sein oder ein numerischer String wenn es möglich ist diesen in einen GMP Wert umzuwandeln.

reps

Reasonable values of reps vary from 5 to 10 (default being 10); a higher value lowers the probability for a non-prime to pass as a "probable" prime.

Dies kann entweder eine resource für einen GMP Wert sein oder ein numerischer String wenn es möglich ist diesen in einen GMP Wert umzuwandeln.

Rückgabewerte

If this function returns 0, a is definitely not prime. If it returns 1, then a is "probably" prime. If it returns 2, then a is surely prime.

Beispiele

Beispiel #1 gmp_prob_prime() example

<?php
// definitely not a prime
echo gmp_prob_prime("6") . "\n";

// probably a prime
echo gmp_prob_prime("1111111111111111111") . "\n";

// definitely a prime
echo gmp_prob_prime("11") . "\n";
?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

0
1
2



add a note add a note User Contributed Notes
gmp_prob_prime
There are no user contributed notes for this page.

gmp_random> <gmp_powm
Last updated: Fri, 10 Oct 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites