write series code
0,7,26,63,124................n terms
import java.util.*; class NumberExample { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.print("Enter value of n: "); int n=input.nextInt(); int sum=0; int m=0; for(int i=1;i<=n;i++){ m=((i*i*i)-1); sum+=m; System.out.print(m+" "); } System.out.println(); System.out.println("Sum of series: "+sum); } }
Ads