Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Primality test Fermat primality test
//g++ 5.4.0 Primality test Fermat primality test #include <bits/stdc++.h> using namespace std; int binPower(int a, int b , int p){ int res = 1; a = a%p; while(b>0){ if(b&1) res = (res * a) %p; a = a*a%p; b>>=1; } return res%p; } bool checkPrime(int n){ for(int i=0;i<10;i++){ int a = 2 + rand()%(n-3); if(binPower(a,n-1,n)!=1){ return false; } } return true; } int main() { if(checkPrime(56)) cout<<"yes"; else cout<<"No"; return 0; }
run
|
edit
|
history
|
help
0
kadane's algorithm 2
designated-inits
HelloWorld
Aplicatie-Proiect
break.cpp
float precision test
Income calculator
Templet
CIDP2k19
read_write_lock_acc