Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Find sum of series
- 1+x/1!+x2/2!+x3/3! upto n times
- */
- import java.util.Scanner;
- public class SumSeries
- {
- public static void main(String args[])
- {
- int n,i,fact=1,j;
- double sum=0;
- Scanner sc=new Scanner(System.in);
- System.out.println("Enter limit");
- n=sc.nextInt();
- for(i=1;i<=n;i++)
- {
- fact=1;
- for(j=1;j<=i;j++)
- fact=fact*j;
- sum+=(double)i/fact;
- }
- System.out.println(sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement