for_each_prime_number(9)
π for_each_prime_number(9) π
okay so bestie, welcome to the Kernel API Manual β this one's a macro that walks the primes for you and honestly? it ate. π
β¨ NAME β¨
for_each_prime_number β literally iterate over each prime upto a value π§
πΈ SYNOPSIS πΈ
for_each_prime_number (prime , max );
(yes the spacing is quirky, that's just how the header file writes it, don't come for it π)
π ARGUMENTS π
primeβ the current prime number in this iteration β¨ lowkey the star of the showmaxβ the upper limit, aka where we stop looking for primes π₯
π¦ DESCRIPTION π¦
Starting from the first prime number 2, iterate over each prime number up to the max value. On each iteration, prime is set to the current prime number. π
max should be less than ULONG_MAX to ensure termination.
β οΈ no like seriously bestie β keepmaxbelowULONG_MAX, that's your whole termination guarantee. don't be the main character who hangs the loop forever ππ
To begin with prime set to 1 on the first iteration use for_each_prime_number_from instead. π«Ά
π SEE ALSO π
- Kernel file
./include/linux/prime_numbers.hπ for_each_prime_number_from(9)β
fr fr that's the whole page, no cap, every flag and caveat intact π hope your iteration slays π β¨
mwah π β from the kernel source living at ./include/linux, dated October 2026, and yes the manual is literally called for_each_prime_number(9) β iconic, periodt ππ¦
π¦ 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