Series 10

Series 10


1+11+121+1331+14641+..........upto n terms.

import java.util.*;

 class Series12
 {
public static void main(String args[])
throws InputMismatchException{
Scanner scan=new Scanner(System.in);

System.out.println("Enter the limit: ");
int n = scan.nextInt();

int i, a=0, s=0;

for(i=0;i < n; i++){

    a = (int)Math.pow(11,i); // generates 1, 11, 121, ...
    s = s + a; 
}

System.out.println("Sum = "+s);

}//end of main
}//end of class

Have something to say? Log in to comment on this post.

0 comments