Write a program to find the series upto n terms: 0,3,8...
Answers
Answered by
1
Answer:
import java.util.*;
public class Series
{
public static void main(String args[ ])
{
Scanner in=new Scanner (System. in);
int a,c,n;
System.out.println("Enter the value of n");
n=in.nextInt();
for(a=1;a<=n;a++)
{
c=Math.pow(a,2)-1;
System.out.println("The series is ="+c);
}
}
}
Explanation:
In the given series it is the subtractive result of 1 from the square of the numbers.
Such that,
(1×1)-1
=1-1
=0
(2×2)-1
=4-1
=3
(3×3)-1
=9-1
=8
And vice versa.
Similar questions