Prime numbers less than 100
Posted by Michał ‘mina86’ Nazarewicz on 12th of December 2010
Anyone working in a big corporation must have been hit by some ‘funny’ mail from a coworker that helps everyone gets through the day. No different at my office — at one point all engineers have been challenged to write the shortest code in C that prints all prime numbers (and only prime numbers) less than a hundred each on separate line.
This is an interesting brain-teaser so posting it here so others may choose to think about it while their code’s compiling.
Of course, a ‘C program’ needs not to be taken too seriously — depending on not too far fetched undefined behaviours of given implementation is all right (but please do not use
exec family of calls; not that I can see how that would help).
By the way, if you’re interested in how this challenge looks solved in Rust, I’ve described that as well.