How to implement wheel factorisation?

This page summarizes the projects mentioned and recommended in the original post on /r/learnpython

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • primesieve

    🚀 Fast prime number generator

  • I've come across this excellent prime sieve on GitHub, and I just want to find out how it generally works. Yes, it's written in C but I plan to make a Python version that uses some of its methods to make a fairly quick prime sieve. However, I'm really not sure how it has implemented wheel factorisation, and no matter how hard I look online, I can't find a good execution of it that works with its segmented approach. Does anyone have any idea how the wheel factorisation is implemented? To my understanding it's a modulus array that tells you which numbers modulo n are definitely not prime leaving you with the candidate primes to check, but I'm not sure how you would implement this inside a segment so that you only check the candidate primes. In the prime sieve on GitHub it somehow finds the next multiple of the prime using its lookup tables, which I cannot decipher.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts