Home » Java » Get odd numbers in a given range – java

Get odd numbers in a given range – java

public class OddNumbers {

    public static void main(String[] args) {
        
        getOdd();
        
    }

    static void getOdd() {
        int left = 3;
        int right = 9;
                
        for (int i = left; i < right + 1; i++) {
           if (i % 2 == 1){
               System.out.println(i);
           }
        }
    }
}
Please follow and like us:

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*