News for hackers. Stuff that matters.
Re:Printing 1 to 1000 without loop or conditionals by wbhart on Monday January 03, 2011 @08:16AM (#2063027)

  #include <stdio.h>
  #include <stdlib.h>

  void main(int j) {
    printf("%d\n", j);
    (main + (exit - main)*(j/1000))(++j);
  }
Somehow the solutions that crash on exit are cheating too much. The above doesn't (obviously) compile to something which uses conditionals at the assembly level. This solution probably wouldn't be by the book. That takes a few more lines of code.

There are no comments on this comment yet.