next_prime_number(9)
π 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 ofULONG_MAXβ andULONG_MAXis 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 π¦
- Kernel file
./lib/math/prime_numbers.c is_prime_number(9)
Signed off from the ./lib/math corner of the kernel β October 2026 β next_prime_number(9) out. π
πβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms