Java Program To Find the Odd numbers up to given input value

 
/*
list of Odd Number Java Example*/
import java.util.*;
import java.lang.*;
import java.Util.Scanner;
 
public class OddNumberList
{
  public static void main(String args[])
  {
  int limit;// upto limit
  System.out.println("Enter your Limit value -");
  Scanner Sc=new Scanner(System.in);// used to scan the input from user
  limit=Sc.nextInt();
  System.out.println("Odd Number List Between 1 to" +limit);
  for(int i=1;i<=limit;i++)
    {
      if(i%2!=0)// odd logic
     {
      System.out.print(i +" " + "|");
     }
    }
  }
}
 

Cookies Consent

This website uses cookies to ensure you get the best experience on our website.

Read More