Sat. Sep 26th, 2020

Program to Create Geometric Sequence in java programming language by using user Input.

import java.util.Scanner;
 class Sequence
     public static void main(String args[])
 int n=5;   //limit

int r=2;  //common ratio

 int a=2;   //terms

 int sum=0;  //sum of the series

 Scanner sc=new Scanner(;//take input from user

 System.out.print("Enter a first term:");


 System.out.print("Enter n limit:"); 


System.out.print("Enter r common ratio : ");

 r=sc.nextInt(); for(int i=1;i<=n;i++)


     a=a*r;     //multiply different with terms

Enter a first term:8
 Enter n limit:6
 Enter r common ratio : 2
 8 16 32 64 128 256
 Process completed.   


Leave a Reply

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