for_each_prime_number(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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 show
  • max β€” 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 β€” keep max below ULONG_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 🌈


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