next_prime_number(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– NAME πŸ’–

next_prime_number β€” return the next prime number. This little icon lives in the Kernel API Manual, and yes bestie, it's giving math-girlie main character energy. ✨


✨ SYNOPSIS ✨

unsigned long next_prime_number (unsigned long x );

πŸŽ€ ARGUMENTS πŸŽ€

  • x β€” the starting point for searching to test. Like, that's where the search starts, okay? 🫢

🌸 DESCRIPTION 🌸

Okay so real talk: a prime number is an integer greater than 1 that is only divisible by itself and 1 β€” no side quests, no extra factors, periodt. πŸ’…

The set of prime numbers is computed using the Sieve of Eratoshenes β€” yes, that's the spelling on this page, do not come for me β€” and the way it works is: on finding a prime, all multiples of that prime are removed from the set, enabling a fast lookup of the next prime number larger than x. The way that fast lookup ate, honestly? Obsessed. πŸ”₯

Heads up, bestie: if the sieve fails (memory limitation), the search falls back to using slow trial-divison, up to the value of ULONG_MAX β€” and ULONG_MAX is reported as the final prime as a sentinel. So like, sentinel behaviour, not a casual regular-prime vibe. 😭

πŸ’« RETURN πŸ’«

The next prime number larger than x. That's it, that's the tea. πŸ«ΆπŸ“


πŸ¦‹ SEE ALSO πŸ¦‹


Signed off from the ./lib/math corner of the kernel β€” October 2026 β€” next_prime_number(9) out. πŸ’…πŸŽ€βœ¨

πŸ“¦ where this page comes from