0

How to form prime numbrr

C

12th Sep 2019, 9:13 AM
Enoch Asanda Hall
Enoch Asanda Hall - avatar
2 Answers
+ 4
A prime number is an integer that can only be cleanly divided by 1 and itself. To figure out if a number is divisible, you can use the % Operator which gives you the remainder of a division (in this case should be 0). Go on with your tutorial a bit, give it a try, show us your attempt.
12th Sep 2019, 10:42 AM
HonFu
HonFu - avatar
0
At the present moment none knows a formula to get a prime number, as HonFu wrote you can only check divisibility with the modulus operator, to save time you can stop at n/2 if n is the number you're checking, is even faster to stop at square root of n.
12th Sep 2019, 12:28 PM
AndreaC
AndreaC - avatar