Series Of odd Numbers

Write a program to Print series of odd numbers upto desired sequence.


import java.util.Scanner;
class OddSeries
{
   public static void main()
   {
      System.out.println("Enter the number upto which you want the Sequence");
      Scanner in = new Scanner(System.in);
      int x = in.nextInt();
      for(int i=1;i<x;i++)
      System.out.print((2*i-1)+", ");
      System.out.print((2*x-1)+". ");
   }
}



For Any Desired Program comment below. WE WILL TRY OUR BEST TO MAKE THAT PROGRAM AVAILABLE.


Comments

Popular Posts