79589706

Date: 2025-04-24 02:00:18
Score: 0.5
Natty:
Report link

Since you are only going to 100, you only need to test for divisibility by 2, 3, 5, and 7. That should be a no-brainer not requiring the Miller-Rabin primality test. And, as done with the best sieve of Eratothsenes above, you can only consider numbers of form 6n+1 and 6n-1, so you don't even need to test for divisibility by 2 or 3.

Side show: It is easy to test a number for divisibility by 2, 3, or 5 just by looking at it. Do you want to know how to bust a big number down so you can easily test for divisibility by 7, 11, and 13 just by looking? Easy. Suppose the number is 123456. Subtract the 123 from the 456 to get 333. This has the same remainder modulo 7, 11, and 13. Do not be afraid of negative results; just add 1001 to make it positive.

Check for divisibility by 7: add double the hundreds digit to the remaing two, 6+33 = 39 = 4mod7.

Check for divisibility by 11: subtract the tens digit from the sum of the hundreds and ones digits, 6-3 = 3. So we have 3 mod 11.

Check for divisibility by 13: I do this the hard way, subtracting multiples of 13. Sorry. I would think 333, 203, 73, 21, 8. That is 123456 modulo 13.

There is a great book that I highly recommend: "Dead Reckoning" by Ron Doerfler.

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: richard1941