javaprograms

javaprograms

write series code

0,7,26,63,124................n terms

View Answers

September 9, 2011 at 3:18 PM

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);
    }
}









Related Tutorials/Questions & Answers:
javaprograms
javaprograms
Advertisements
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms
javaprograms - Java Beginners
javaprograms - Java Beginners
javaprograms - Java Beginners

Ads