Go to Top

Saturday, 2 July 2011

To print and find the sum of a given series

Question 15 : Write a program in Java to print and find the sum of the given series-

S = 1+2+4+7+11+......+n

Java Program : 

public class series_1
 public static void main(int n)
     int i,d;
     int s=1;
     System.out.println("The generated numbers are : ");
    System.out.println("\nThe sum of the generated numbers = "+d);

No comments:

Post a Comment