Take the 2-minute tour ×
Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.

From the famous FizzBuzz challenge,

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".

But here

In this challenge, you don't need to print anything, instead, your program should count on variables, the number of Fizz found, the number of Buzz, the number of FizzBuzz and the number of the rest (non multiples of 3 and 5).

And then, print the numbers found, like this:

From 1 to 100
Fizz: 30
Buzz: 17
Others: 53

FizzBuzz: 6 (this don't count, they were already incremented on Fizz and Buzz)

Hey, hold there...

What do you mean with this don't count, they were already incremented on ping and pong?
Yes, you should increment all multiple of 3 on the Fizz counter, all multiples of 5 on the Buzz counter, and also all multiples of 3 and 5 on the FizzBuzz counter.
It means that if you sum Fizz + Buzz + Others it will be equal to 100 already.
The FizzBuzz counter is just to know how many multiples of 3 and 5 we have.


  • This is a code-gold, in one week, the shortest wins.
  • Any programming language will be accepted.
share|improve this question
Closely related: projecteuler.net/problem=1 –  David Carraher Dec 18 '12 at 0:13
They are not even "far related". If you don't wanna play, just ignore it. –  BernaMariano Dec 18 '12 at 0:19
btw, that was not my downvote. –  David Carraher Dec 18 '12 at 0:35
and who downvoted could at least explain why, ethically saying... –  BernaMariano Dec 18 '12 at 0:37
For future reference, there is a (actually a sequence of several) "sandbox(s)" on meta where you can get advice on potential challages before going live. –  dmckee Dec 18 '12 at 1:13

5 Answers 5

This is the most efficient method of calculating the number of fizzes and buzzes:

Integer fizz = 100 / 3;
Integer buzz = 100 / 5;
Integer other = 100 - fizz - buzz;
Integer fizzBuzz = 100 / (3 * 5);

Note that 3 and 5 could be substituted for any positive prime numbers, and 100 could be substituted for any positive number whatsoever.

share|improve this answer

Python 2 (101)

print"From 1 to %d\nFizz: %d\nBuzz: %d\nOthers: %d\nFizzBuzz: %d"%(n,n/3-g,n/5-g,8*n/15,g*2)
share|improve this answer

APL 94

('Fizz:' 'Buzz:' 'Others:' 'FizzBuzz:'),[1.1]n[1 2],(100-+/n[1 2]),(n←∊+/0=(⊂3 5 15)|¨⍳100)[3]
share|improve this answer


131 characters

* I used step iterators for counters
d=f=b=0;15.step(100,15){d+=1};5.step(100,5){b+=1};3.step(100,3){f+=1};puts "Buzz:#{f}\nFizz:#{b}\nBuzzFizz:#{d}\nOthers:#{100-f-b}"
share|improve this answer


#include <stdio.h>
int main(){printf("Fizz: %d\nBuzz: %d\nOthers: %d\n",100/3,100/5,100-100/3-100/5);return 0;}
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.