fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. for (int i = 0; i <= 100 ; i++) {
  13. final String s;
  14.  
  15. if (i%3 == 0) {
  16. System.out.print("fizz");
  17. s = "";
  18. } else {
  19. s = "" + i;
  20. }
  21.  
  22. final String s2;
  23. if (i%5 == 0) {
  24. System.out.print("buzz");
  25. s2 = "";
  26. } else {
  27. s2 = s;
  28. }
  29.  
  30. System.out.println(s2);
  31. }
  32. }
  33. }
Success #stdin #stdout 0.12s 320576KB
stdin
Standard input is empty
stdout
fizzbuzz
1
2
fizz
4
buzz
fizz
7
8
fizz
buzz
11
fizz
13
14
fizzbuzz
16
17
fizz
19
buzz
fizz
22
23
fizz
buzz
26
fizz
28
29
fizzbuzz
31
32
fizz
34
buzz
fizz
37
38
fizz
buzz
41
fizz
43
44
fizzbuzz
46
47
fizz
49
buzz
fizz
52
53
fizz
buzz
56
fizz
58
59
fizzbuzz
61
62
fizz
64
buzz
fizz
67
68
fizz
buzz
71
fizz
73
74
fizzbuzz
76
77
fizz
79
buzz
fizz
82
83
fizz
buzz
86
fizz
88
89
fizzbuzz
91
92
fizz
94
buzz
fizz
97
98
fizz
buzz