Display the Series 0 4 18 48 100 180 ... n
Logic:
0 X (1 X 1) = 0
1 X (2 X 2) = 4
2 X (3 X 3) = 18
3 X (4 X 4) = 48
4 X (5 X 5) = 100
5 X (6 X 6) = 180
6 X (7 X 7) = 294
import java.util.*;
class Series_0_4_18_48_100_180
{
public static void main(String args[])
{
int i, n,num=0;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the terms of Series = ");
n=sc.nextInt();
for(i=1;i<=n;i++)
{
num=(i*i)*(i-1);
System.out.print(num+" ");
}
}
}
No comments