Hey I am confused why we didn’t include 4,6,8,9 squared to test if they are prime?
If a number is not divisible be 2 then it’s not divisible by 4 or 8. Similarly, if a number is not divisible by 2 and 3 then it’s not divisible by 6. We mostly don’t care about checking composites in a range because they’re made up of prime constituents (which we check), so checking them would be kinda redundant.
4,6,8 are all multiples of 2 so if a number is not divisible by 2 then all its multiples will also not divide the number.
Similarly for 9, if a number is not divisible by 3 then 3x3 will certainly not be a factor as well.
The trick is to only use prime numbers to the nearest square root of the number. All other numbers are just a product of the primes and can safely skip testing divisibility test for such numbers.
