fork download
  1. #include <stdio.h>
  2.  
  3. #define COUNT(number, divisor, result) \
  4. while (number && number % divisor == 0) { \
  5. ++result; \
  6. number /= divisor; \
  7. }
  8.  
  9. #define PRINT(phrase, count) while (count-- > 0) printf(phrase);
  10.  
  11. int main(void) {
  12. int i;
  13. for (i = 0; i <= 100; ++i) {
  14. if (i % 3 && i % 5) {
  15. printf("%d\n", i);
  16. continue;
  17. }
  18. int fizz_count = 0, buzz_count = 0, fizzbuzz_count = 0;
  19. int j = i;
  20. COUNT(j, 15, fizzbuzz_count)
  21. COUNT(j, 3, fizz_count)
  22. COUNT(j, 5, buzz_count)
  23. PRINT("Fizz", fizz_count)
  24. PRINT("FizzBuzz", fizzbuzz_count)
  25. PRINT("Buzz", buzz_count)
  26. printf("\n");
  27. }
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0s 2112KB
stdin
Standard input is empty
stdout
1
2
Fizz
4
Buzz
Fizz
7
8
FizzFizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
FizzFizz
19
Buzz
Fizz
22
23
Fizz
BuzzBuzz
26
FizzFizzFizz
28
29
FizzBuzz
31
32
Fizz
34
Buzz
FizzFizz
37
38
Fizz
Buzz
41
Fizz
43
44
FizzFizzBuzz
46
47
Fizz
49
BuzzBuzz
Fizz
52
53
FizzFizzFizz
Buzz
56
Fizz
58
59
FizzBuzz
61
62
FizzFizz
64
Buzz
Fizz
67
68
Fizz
Buzz
71
FizzFizz
73
74
FizzBuzzBuzz
76
77
Fizz
79
Buzz
FizzFizzFizzFizz
82
83
Fizz
Buzz
86
Fizz
88
89
FizzFizzBuzz
91
92
Fizz
94
Buzz
Fizz
97
98
FizzFizz
BuzzBuzz