Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


k.jahangir kumar
javaprograms
1 Answer(s)      3 years and 3 months ago
Posted in : Java Beginners


write series code

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


Advertisement
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:
Advertisements
 

 

 

DMCA.com