06-30-2022, 12:25 PM
(06-30-2022, 10:49 AM)SMcNeill Wrote: Here's something I noticed the other day, which I thought might interest you, since you've written a ton of programs regarding prime numbers -- most primes tend to be multiples of 6, +/- 1!
5 is 6 -1
7 is 6 + 1
11 is 6 * 2 -1
13 is 6 * 2 +1
17 is 6 * 3 -1
19 is 6 x 3 +1
... and so on.
I don't know how far the pattern continues (past 100, I think), but you might want to play with it some and see how it holds up in general. It may be a quicker way to generate a list of primes than using the Sieve which I've seen you implement often in the past. My ass is still kicked from my last doctor's visit and all, and I'm not up to coding on it at the moment, but I figured I'd share the observation in case it interested you.
Yes it is a small 6 wheel: 2*3, next one up is 30 wheel: 2*3*5, and next one up is 210 wheel: 2*3*5*7
Wheels speed up Prime Sieving because there is no IF checking and much fewer loops. Smallest wheel is 2: odd and even numbers. Euclid: Primes are Infinite because Wheel + 1 is not divisible to all previous known primes (but not necessarily prime though very often is).
b = b + ...