Update: added a benchmark for performance comparison and updated the code to no longer rely on a fatal error to exit.
It started with one question:
Print numbers from 1 to 1000 without using any loop or conditional statements. Don’t just write the printf() or cout statement 1000 times.
How would you do that using C or C++?
Source: Stack Overflow
My favorite answer was an amazing example of obscure C. Using math to iterate between two function pointers (printf and exit). And while it brought back memories of my C days, I kind of left it at that.
Later in the day, one of my co-workers messaged me with his version of a 1-1000 iterator in PHP. So naturally, I had to write my own version.
