Search code examples
primesfactorizationsieve-algorithmwheel-factorization

2-3-5-7 wheel factorization seems to skip prime number 331


When following the procedure on wikipedia for wheel factorization, I seem to have stumbled into a problem where the prime number 331 is treated as a composite number if I try to build a 2-3-5-7 wheel.

With 2-3-5-7 wheel, 2*3*5*7=210. So I setup a circle with 210 slots and go through steps 1-7 without any issues. Then I get to step 8 and strike off the spokes of all multiples of prime numbers, I eventually strike off the spoke rooted at 121, which is a multiple of 11, which is a prime. For the spoke rooted at 121, 121 + 210 = 331. Unfortunately, 331 is a prime number.

Is the procedure on Wikipedia incorrect?

Or did I misunderstand the procedure, and should have only struck out spokes that are multiples of 2, 3, 5, and 7, but not any of the other primes less than 210?


Solution

  • Wikipedia is correct.

    331 is in the 1 spoke of the wheel. The spoke is not shaded, so 331 is potentially prime. And in fact, it is prime.

    121 is also in the 1 spoke of the wheel, so 121 is potentially prime. That is, it is not eliminated as a prime by the wheel. However, it is not prime.

    The wheel doesn't allow you to make any inference about the primality of 331 based on the non-primality of 121. Sorry.

    I have an implementation of wheel factorization at my blog, if you want to look at it.