Computer Science, asked by NeneAmano, 1 year ago

Java program to print sum of 1+x/1!+x^2/2!+x^n/n!

Answers

Answered by vaibhavamishra
0
thats all...........
Attachments:
Answered by BrainlyPromoter
2

import java.util.Scanner;


class Lab1


{


   public static double d(double n)


   {


       double fact = 1, count = 1, div = 0, sum = 1;


       for(;count<=n;count++)


       {


           for(double count2=1;count2<=count;count2++)


           {


               fact = fact * count2;


           }


           div = count / fact;


           sum = sum + div;


       }


       return sum;


   }



   public static void main(String args[])


   {


       Scanner BrainlyPromoter = new Scanner(System.in);


       System.out.println("Sum of the following series is to be printed: 1+x/1!+x^2/2!+x^3/3!+x^4/4!+.......+x^n/n!");


       System.out.println("Please enter the value of required variable as given in the series.");


       System.out.println("Please enter the value of 'x'.");


       int n = BrainlyPromoter.nextInt();


       double sum = d(n);


       System.out.println("The sum of the series will be: "+sum);


   }


}

Attachments:
Similar questions