write a program of java to display the series of 8 35 80 143
Answers
Answered by
2
Question:-
write a program of java to display the series
8 35 80 143....N
Logic:-
8=3²-1
35=6²-1
80=9²-1
143=12²-1
Program:-
import java.util.*;
class Series
{
public static void main()
{
Scanner sc=new Scanner(System.in);
int n, a=3,b, i;
System.out.print("Enter the number of terms: ");
n=sc.nextInt();
for(i=1;i<=n;i++)
{
b=a*a-1;
System.out.print(b+" ");
a+=3;
}
}
}
Similar questions
Social Sciences,
2 months ago
Math,
2 months ago
History,
5 months ago
Physics,
5 months ago
Science,
10 months ago