Primality Testing, Factorization, and Sieving Implementation

I figured that for my daily post today, I would learn Javascript and figure out how to make this website more interactive. I decided to write primality testing and prime factorization scripts and include them below:

Update: I've included a prime sieving script. Additionally, these only work for integers from 2 to 2^53.

Test if a number is prime:

Factor a number into its prime components:

Calculate all prime numbers under n:

These algorithms are only moderately faster over the most naive implementations. There are much faster algorithms out there!

1 thought on “Primality Testing, Factorization, and Sieving Implementation”

Leave a Reply