PROGRAM TO FIND N'TH TERM OF GEOMETRIC PROGRESSION

import java.util.Scanner;
import java.lang.Math;
class GP
{
public static void main(String[] args)
{
Scanner s=new Scanner(System.in);
System.out.println("enter how many text cases do you want");
int t=s.nextInt();
double a,b;
int c,f;
double r,n;
for(int i=0;i<t;i++)
{   
System.out.print("first two term");
a=s.nextInt();
b=s.nextInt();
System.out.println("enter which term to find");
c=s.nextInt();
r=b/a;
n=a*(Math.pow(r,(c-1)));
              f=(int) Math.floor(n);
System.out.println("n'th term ="+f);

}
}
}

Comments

Popular posts from this blog

Problem Statement Of Real Estate Use Cases

Problem Statement Of Bank Marketing analysis

Hadoop