JuliaMath / Primes.jl

Prime numbers in Julia
Other
99 stars 32 forks source link

use cached primes for fast `isprime` of small numbers #113

Closed oscardssmith closed 2 years ago

oscardssmith commented 2 years ago

This reduces the time to 8ns from 250ns for @btime isprime($(prevprime(2^16))). It's slightly slower for small non-primes (numbers with a smallest factor less than 13), but it means that for all small numbers, isprime will take very little time (less than 10ns)

oscardssmith commented 2 years ago

Closing as obsoleted by https://github.com/JuliaMath/Primes.jl/pull/117