GMP_PROB_PRIME(3) 1 GMP_PROB_PRIME(3)gmp_prob_prime - Check if number is "probably prime"
SYNOPSIS
int gmp_prob_prime (GMP $a, [int $reps = 10])
DESCRIPTION
The function uses Miller-Rabin's probabilistic test to check if a number is a prime.
PARAMETERS
o $a
- The number being checked as a prime. Either a GMP number resource in PHP 5.5 and earlier, a GMP object in PHP 5.6 and later, or
a numeric string provided that it is possible to convert the latter to a number.
o $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. Either a GMP number resource in PHP 5.5 and earlier, a GMP object in PHP 5.6 and later, or a numeric string
provided that it is possible to convert the latter to a number.
RETURN VALUES
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.
EXAMPLES
Example #1
gmp_prob_prime(3) example
<?php
// definitely not a prime
echo gmp_prob_prime("6") . "
";
// probably a prime
echo gmp_prob_prime("1111111111111111111") . "
";
// definitely a prime
echo gmp_prob_prime("11") . "
";
?>
The above example will output:
0
1
2
PHP Documentation Group GMP_PROB_PRIME(3)
Check Out this Related Man Page
GMP_CLRBIT(3) 1 GMP_CLRBIT(3)gmp_clrbit - Clear bitSYNOPSIS
void gmp_clrbit (GMP $a, int $index)
DESCRIPTION
Clears (sets to 0) bit $index in $a. The index starts at 0.
PARAMETERS
o $a
-Either a GMP number resource in PHP 5.5 and earlier, a GMP object in PHP 5.6 and later, or a numeric string provided that it is
possible to convert the latter to a number.
o $index
- The index of the bit to clear. Index 0 represents the least significant bit.
RETURN VALUES
A GMP number resource in PHP 5.5 and earlier, or a GMP object in PHP 5.6 and later.
EXAMPLES
Example #1
gmp_clrbit(3) example
<?php
$a = gmp_init("0xff");
gmp_clrbit($a, 0); // index starts at 0, least significant bit
echo gmp_strval($a) . "
";
?>
The above example will output:
254
NOTES
Note
Unlike most of the other GMP functions, gmp_clrbit(3) must be called with a GMP resource that already exists (using gmp_init(3) for
example). One will not be automatically created.
SEE ALSO gmp_setbit(3), gmp_testbit(3).
PHP Documentation Group GMP_CLRBIT(3)
if test $b -ne
then
echo "\n\n\n\tPassword reset has been done successfully"
else
echo "\n\n\n\tAn error occurred"
fi
i want to check whether $b is non-numeric so how to do that? (3 Replies)
Salve sono alle prime prese con i comandi sed e awk.
Nel primo caso vorrei creare uno script in cui viene estratto la partizione maggiore. in pił ci deve essere un messaggio d'avviso se supera l' 80 % dello spazio occupato.
Ho pensato di usare il comando df -h, e l' awk. Mi potete dire come?... (1 Reply)
I am trying to set up the gnu multiple precision arithmetic library for some c++ programming I have to do.
I am using a system with mac osx 10.6.3 and do NOT have root user access.
I'm trying to use gmp 5.0.1.
Since I don't have root user access, I had to install to a different directory
Thus... (3 Replies)
Write a function named isPrime which accepts one integer parameter, say x. Have the function return TRUE if x is a prime. Otherwise, have it return FALSE.
b) Write a program that keeps asking the user for an integer say k. As long as k is greater than 0, the program will call... (1 Reply)
I've testing the following code:
echo test.txt | cut -d . -f1and get the output "text"
So why can't i assign the command to a variable?
VAR='"echo test.txt | cut -d . -f1"'
echo $VAR (5 Replies)
Hello Forum members,
What is the prime difference between fork and Vfork and when to prefer in our aapications this Vfork.
Thanks
Siva Ranganath (2 Replies)
The problem I'm having is that when you put in the two numbers the answer is just prime.... nothing. I cannot figure this out ive been working on this forever, can someone please god just tell me how to fix this without encrypted "hints".
#include <iostream>
#include <cmath>
using... (3 Replies)
I am using ubuntu. I have written a program to calculate prime factors. it works perfectly fine till entered number is less than 9989 (or so ) but when one enters a number higher than that, for example 15000, it does not work. Can anyone guide me whats the problem ? although new codes are welcome,... (2 Replies)
I have a factor program that runs and outputs to stdout all the prime numbers that are specified in the given paramters, in this case 30000000-31000000.
Command:
factor/factor 30000000-31000000
Sample output:
30999979 = 30999979
30999980 = 2^2 5 11 140909
30999981 = 3 10333327... (6 Replies)