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
Dynamic Programming For Combinatorics - 1
lab17feb22x4B.cpp
so
The Menu
replace-30-Seconds-of-C++
aju
Expected types
zeroout
Test 4(2017)
Finding Ocean