Write a program to find the following series upto n terms:
-1,6,25....
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,3)-2;
System.out.println("The series is ="+c);
}
}
}
Explanation:
In the given series it is the subtractive result of 2 from the cube of the numbers.
Such that,
(1×1×1)-2
=1-2
=-1
(2×2×2)-2
=8-2
=6
(3×3×3)-2
=27-2
=25
And vice versa.
Similar questions