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:
Anonymous2008-04-25 18:14
esle
Name:
Anonymous2008-04-25 18:14
#!/usr/local/bin/ploki
LET i += 1
IF i > 100
END
END IF
WUNT \AUSG @FIZZBUZZi
IF
FOR FIZZBUZZ LEET r
IF \@ % 3 = 0
LET r "Fizz"
FI
IF \@ % 5 = 0
LET r _= "Buzz"
FI
IF @NOT r
LET r \@
FI
KTHX r
Name:
Anonymous2008-04-25 18:36
UM LOL C
void fizzbuzz()
{
for(int x=1;x<=100;x++)
{
if(x%3==0) {printf("FIZZ\n");}
else if(x%5==0) {printf("BUZZ\n");}
else if(x%15=0) {printf("FIZZBUZZ\n");}
else {printf("%i",x);}
}
}
too lazy to format. simple shit yo
Sage for FizzBuzz. Sure, I've met "Programmers" who couldn't code it, but their numbers are few.
The problem's real nature lies in making people who read it think "Hey, I could solve that!" and feel good about themselves. They then feel somehow compelled to post their own solution, to show that "Hello, I'm anonymous, and I am superior because I can solve a problem any eight-year old who've ever sat down at a BASIC prompt can handle."
Clever obfuscations or circumlocutions are still encouraged.
(mod x1 x2) is R6RS and (modulo x2 x2) is R5RS what the fuck.
those using non r6rs compilers (define mod modulo) i guess
Name:
Anonymous2008-04-25 23:50
>>63
DIEROM SEI
LDA #0
STA 0
HALT JMP HALT
.ASC "OMG WHERE IS YOUR KERNAL RESET ROUTINE NOW?"
Name:
Anonymous2008-04-26 0:47
(defun fizzbuzz ()
(format t "~{~a ~}"
(loop for i from 1 upto 100
when (= (mod i 15) 0) collect "FizzBuzz"
when (= (mod i 3) 0) collect "Fizz"
when (= (mod i 5) 0) collect "Buzz"
else collect i)))
Or in my custom Lisp where fizzbuzz is a builtin:
(fizzbuzz)
Name:
Anonymous2008-04-26 1:43
The fun thing about FizzBuzz (other than writing obfuscated versions) is to write versions that seem correct but aren't, present them to others and see if they spot the mistake.
#include <stdio.h>
int main() {
int i, f, b;
for(i=1;i<=100;i++) {
if((f = !(i%3)) || (b = !(i%5)))
printf("%s%s", f ? "Fizz" : "", b ? "Buzz" : "");
else
printf("%d", i);
printf("\n");
}
return 0;
}
MD5 (solution) = 78a1dc71c6d126a040c7da4f006f717c
Name:
Anonymous2008-04-26 2:20
>>67
Apart from newlines, I don't see anything wrong with it
>>71
I'm going to take a stab at it:
in if((f = !(i%3)) || (b = !(i%5)))
when the condition is evaluated, if the first one is true then the condition is true so the second isn't evaluated. So b doesn't change from its state from iteration 5.
if you write instead:
#include <stdio.h>
int main() {
int i, f, b;
for(i=1;i<=100;i++) {
f = !(i%3);
b = !(i%5);
if (f || b) {
printf("%s%s", f ? "Fizz" : "", b ? "Buzz" : "");
} else {
printf("%d", i);
}
printf("\n");
}
return 0;
}
both statements are should be evaluated and it seems to work correctly.