Check if a number is prime

in #steemeitducation4 years ago

Screenshot_20180331-203731_1522507996627.jpg

Rule

Step 1
Take the square root of the number.

Step 2
Round off the square root to the immediately lower interger. Call this number z.

Step 3
Check for the divisibility of the number by all prime numbers less than equal to z, If there is no such prime number which divides N, then the number N will be prime.

Examples

71
To check if 71 is prime, take the square root of 71.
The square root rounded off to a lower integer would be 8.
Now, Check if 71 is divisible by any prime number from 2 to 8, you will find out it is not. Hence, 71 is a prime nuumer.

97
To check if 97 is prime, take the square root of 97.
The square root rounded off to a lower integer would be 9.
Now, Check if 97 is divisible by any prime number from 2 to 9, you will find out it is not. Hence, 97 is a prime nuumer.

Coin Marketplace

STEEM 0.46
TRX 0.08
JST 0.059
BTC 48838.47
ETH 4146.99
BNB 547.49
SBD 5.82