Files
  • Main.java
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class Main {
    public static void fizzbuzz( int x ) {
        String div3, div5, n;   // var declaration
 
        for ( int i = 1; i < x; i++ ) {
            div3 = "";
            if ( i % 3 == 0 ) {
                div3 = "fizz";
            }
            div5 = "";
            if ( i % 5 == 0 ) {
                div5 = "buzz";
            }
            n = "";
            if ( div3 == "" && div5 == "" ) {
                n = String.valueOf(i);
            }
            System.out.println(div3 + div5 + n);
        }
    }
    
    public static void main(String[] args) {
        fizzbuzz(100);
    }
}
java version "1.8.0_31" Java(TM) SE Runtime Environment (build 1.8.0_31-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)