+ 1

Do we use array fo declaration of prime numbers?

There is any mathematical code to declare prime number or we only use arrays for it.

26th May 2018, 11:56 AM
Bashir Ahmad
Bashir Ahmad - avatar
2 Respuestas
+ 1
for(i = 2; i <= n / 2; ++i) { if(n % i == 0) { isPrime = false; break; } } you just have to use this logic
26th May 2018, 12:05 PM
MsJ
MsJ - avatar
0
Mohit the coder (M.S.D) thanks for the great answer. I am just a beginner.
26th May 2018, 12:10 PM
Bashir Ahmad
Bashir Ahmad - avatar