How can we check if a number is prime or composite?
Let 'x' be the number you check:
x² = x * x
Say √(x) = y
√(x) = y
y = a * b
Now if we were to assign a value to x, like x = 123, then:
√(123) ~ between √(121) and √(144) closer to √(121) because
123 - 121 = 2
144 - 123 = 21
2 < 21
midpoint
144-121= 23
23/2 = 11.5
and so we know that √(123) ~ is close to 11, a little higher somewhere between 11.1 or 11.09.
y = a * b
Let's say approximate for y is 11.1
So either a or b have to be less than 11.1
1 * 11.1
2 * 5.55
...
We just have to check the numbers less than the whole number 11 to see if 123 is divisible.
123 / 2 = WE KNOW THIS WON'T WORK BECAUSE LAST DIGIT ISN'T EVEN.
123 / 3 = WE KNOW THIS WILL WORK BECAUSE 1+2+3= 6, AND 6 IS A MULTIPLE OF 3.
WE CAN STOP HERE.
123 / 4 = WE KNOW THIS WON'T WORK BECAUSE DIDN'T SATISFY "MULTIPLE OF 2"
this is literally just 123 / (2*2) if it helps.
123 / 5 = WE KNOW THIS WON'T WORK BECAUSE LAST DIGIT ISN'T 0 NOR 5.
123 / 6 = SINCE 123 WAS DIVISIBLE BY 3 BUT NOT 2, IT WILL NOT BE DIVISIBLE BY 6.
this is literally just 123 / (2*3) if it helps.
123 / 7 = WILL NOT WORK; CHECK DIVISIBILITY RULE BY 7 BELOW.
123 / 8 = WILL NOT WORK, NOT DIVISIBILE BY BOTH FACTORS OF 8: 2 NOR 4.
this is literally just 123 / (2*4) if it helps.
123 / 9 = WE KNOW THIS WON'T WORK BECAUSE 1+2+3 = 6, AND 6 IS NOT A FACTOR OF 9.
123 / 10 = WE KNOW THIS WON'T WORK BECAUSE LAST DIGIT ISN'T 0.
123 / 11 = WE KNOW THIS WOULDN'T WORK BECAUSE VALUE IS ONLY 2 AWAY FROM NEAREST MULTIPLE OF 11 WHICH IS 121.
Now we just have to check the first one that works. In this case, check 3.
123/3 = 41
Therefore, 123 is NOT a prime, but a composite number.
This trick will help you find out till what number you should bother checking (dividing it by) to see if x is prime or composite.. :)
Extras:
EXPLORING THE MULTIPLE OF SEVEN RULE (really cool watch!):
https://youtu.be/UDQjn_-pDSs
No comments:
Post a Comment