46. TEST IF A NUMBER IS PRIME
 
Home Menu Previous Next


Pick-up the techniques.

Example 1: Test if 23 is a prime.
2+3=5; Not a mutiple of 3.
23 is not a multiple of 7 also. So is a prime.

Example 2: Test if 251 is a prime.

132= 169 & 172= 289
169 < 251 < 289
We have to test upto 13.

Test for 3: 2+5+1 is 8; Not a mutiple of 3.
Test for 7: 25-(2x1)=23; Not a multiple of 7.
Test for 11:
Sum of odd-place digits:3 and
Sum of even-place digits:5;
Difference is 2:
Not a multiple of 11.
Test for 13: 251 >> 25+(4x1)=29; Not a multiple of 13. So is a prime.

Example 3: Test if 631 is a prime.
232 = 529; 292 = 841
We have to test upto 23.

Test for 3: 6+3+1=10 >> 1+0 = 1; Not a mutiple of 3.
Test for 7: 631 >> 63-(2x1) = 61; Not a multiple of 7.
Test for 11:
Sum of odd-place digits:7 and
Sum of even-place digits:3;
Difference is 4;
Not a multiple of 11.
Test for 13: 631 >> 63+(4x1) = 67; Not a multiple of 13.
Test for 17: 631 >> 63-(5x1) = 58; Not a multiple of 17.
Test for 19: 631 >> 63+(2x1) = 65; Not a multiple of 19.
Test for 23: 631 >> 63+(7x1) = 70; Not a multiple of 23.
So 631 is prime.