0
Finding prime number without using loops?
Without using any control statements we have to find wheather the given number is prime or not.
7 Respostas
+ 2
/*check if prime using fermat's little theorem
k^(n-1)mod(n)=1 where n is a prime*/
private static boolean test(int num){
if (Math.pow(2,num-1)%num == 1 || num==1 || num==3){return true;}else {return false;}}
+ 2
No
+ 1
sivasai chandolu in this case it is not a question but a challenge and better off
on your timeline.
+ 1
Thank you sir I'm new to solo learn. I'll post it in my time line.
0
First try yourself or you can take these references.
https://www.sololearn.com/discuss/1301937/?ref=app
https://www.sololearn.com/discuss/1353478/?ref=app
https://www.sololearn.com/discuss/697929/?ref=app
https://www.sololearn.com/discuss/1709615/?ref=app
https://www.sololearn.com/discuss/2034183/?ref=app
https://www.sololearn.com/discuss/1759622/?ref=app
https://www.sololearn.com/discuss/2168940/?ref=app
0
I had solved it but I'm waiting for different code which is not same to my code.
0
Could recursion be classified as a loop?