Post #3954141
2026-07-20 07:55 UTC
Math fedi, help!
I'm looking for a function that calculates the next prime given a starting integer (not guaranteed prime) - i.e. what's the smallest prime larger than this number.
It looks like there are some functions for generating primes but nothing with a minimum and all the other articles are basically "loop and test each one" - maybe using a sieve function.
Does a nicer mathematic approach exist?
#Math #Mathematics #PrimeNumbers #Primes
Replies (2)
-
@BenAveling@infosec.exchange 2026-07-20 08:07
@arichtman@eigenmagic.net if you’d settle for a prime, larger than x, then maybe. But if it has to be the smallest prime larger than x, then no.
-
@arichtman@eigenmagic.net 2026-07-20 14:24
For those following along at home so far the score is thus: Prime numbers: 2 Me: (stepped on a landmine, DQed)