0

Finding prime number without using loops?

Without using any control statements we have to find wheather the given number is prime or not.

2nd Mar 2020, 6:29 AM
sivasai chandolu
sivasai chandolu - avatar
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;}}
2nd Mar 2020, 9:31 AM
Sumit Programmer😎😎
Sumit Programmer😎😎 - avatar
+ 2
No
2nd Mar 2020, 8:00 AM
sivasai chandolu
sivasai chandolu - avatar
+ 1
sivasai chandolu in this case it is not a question but a challenge and better off on your timeline.
2nd Mar 2020, 7:02 AM
Oma Falk
Oma Falk - avatar
+ 1
Thank you sir I'm new to solo learn. I'll post it in my time line.
2nd Mar 2020, 7:05 AM
sivasai chandolu
sivasai chandolu - avatar
0
I had solved it but I'm waiting for different code which is not same to my code.
2nd Mar 2020, 6:47 AM
sivasai chandolu
sivasai chandolu - avatar
0
Could recursion be classified as a loop?
2nd Mar 2020, 7:58 AM
Seb TheS
Seb TheS - avatar