Print odd numbers using for loop

Suman Barik
0

 // Use this editor to write, compile and run your Java code 


public class HelloWorld {

    public static void main(String[] args) {

        //2i = Even Numbers = 0, 2, 4, 6, 8;

        //2i+1 = Odd Numbers = 1, 3, 5, 7, 9;

        int n = 3;

        for (int i =0; i<n; i++){

        System.out.println(2*i+1);

        }

    }

}

Post a Comment

0Comments
Post a Comment (0)