MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1vda9j/deleted_by_user/cerh58t/
r/ProgrammerHumor • u/[deleted] • Jan 16 '14
[removed]
446 comments sorted by
View all comments
Show parent comment
1
What do you consider answering correctly? Something like
for i = 0, i++, i = 100 if ((i mod 3) + (i mod 3) > 0 ) print i else if i mod 3 = 0 print Fizz if i mod 5 = 0 print Buzz print endline endfor
Or are you expecting proper syntax etc
EDIT: precoffee stupidity removed.
7 u/[deleted] Jan 17 '14 You failed. Fizz and Buzz are both to be capitalized. 0 u/[deleted] Jan 17 '14 [deleted] — view deleted comment 3 u/admiralranga Jan 17 '14 Ooops 1 u/tangerinelion Jan 17 '14 Inside the typical choices are:string out = ""; if(i%3 == 0) { out += "Fizz"; } if(i%5 == 0) { out += "Buzz"; } if(out.length()) { print out; } else { print i; }or to consider the 4 possible choices explicitly:if(i%15 == 0) { print "FizzBuzz"; } else if(i%5 == 0) { print "Buzz"; } else if(i%3 == 0) { print "Fizz;" } else { print i; }You do not want to add i%3 and i%5. You want the boolean AND, as i%3 == 0 && i%5 == 0 implies i%15 == 0. But i%3 + i%5 is only 0 for i == 15*n (n an int).
7
You failed. Fizz and Buzz are both to be capitalized.
0
[deleted] — view deleted comment
3 u/admiralranga Jan 17 '14 Ooops
3
Ooops
Inside the typical choices are:
string out = ""; if(i%3 == 0) { out += "Fizz"; } if(i%5 == 0) { out += "Buzz"; } if(out.length()) { print out; } else { print i; }
or to consider the 4 possible choices explicitly:
if(i%15 == 0) { print "FizzBuzz"; } else if(i%5 == 0) { print "Buzz"; } else if(i%3 == 0) { print "Fizz;" } else { print i; }
You do not want to add i%3 and i%5. You want the boolean AND, as i%3 == 0 && i%5 == 0 implies i%15 == 0. But i%3 + i%5 is only 0 for i == 15*n (n an int).
View all comments
Show parent comment
1
u/admiralranga Jan 17 '14 edited Jan 17 '14
What do you consider answering correctly? Something like
Or are you expecting proper syntax etc
EDIT: precoffee stupidity removed.