Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

90% of /prog/ can't write FizzBuzz

Name: The antagonist 2008-04-25 12:38

Prove me wrong

Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".

Name: Anonymous 2008-05-01 3:05

>>165
* changed || to && (was causing erroneous behavior)
* removed redundant value checks
* removed the static variable (poor form)
* added declarations for printf and putchar
* tail-call optimized

#include <stdio.h>
int main(int i, char **argv) {
    return argv ? main(1,NULL) : i > 100 ? 0 : ((
        (i%3 || (printf("Fizz"), 0))
        && (i%5 || (printf("Buzz"), 0))
    ) && printf("%d",i), putchar('\n'), main(i + 1, NULL));
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List