Re:Printing 1 to 1000 without loop or conditionals
by pmorici on Monday January 03, 2011 @12:24AM
(#2062208)
doesn't that violate the "w/o conditionals" part?
Re:Printing 1 to 1000 without loop or conditionals
by hardy263 on Monday January 03, 2011 @01:35AM
(#2062361)
Technically, he's using relational operators
if/else are conditionals that evaluate the boolean datatypes that result from the relational operation.
Is it breaking the rule? Not really.
Is it a loophole? Probably.
The original question probably intended it to mean "no comparing" rather than "no conditional statements"
#include <stdio.h>
int show(int i) { printf("%d\n",i); return( (i>=1000) || show(i+1)); }
int main(int argc,char argv) { return show(1); }