Computer Science, asked by abhinavjain1307, 11 months ago

Q12. Write a java program to find the sum of the series :
S = 1! + 2! + 3!+…….N!

where N! denotes the factorial of N​

Answers

Answered by Anonymous
17

Explanation:

#a java program to find the given sum series

class Factorial

{

public static void main (String args[])

{

Scanner sc=new Scanner (System.in);

System.out.println("enter the value of N");

int n=sc.nextInt();

int s=0;

int fact;

for(int i=1;i<=n;i++)

{

fact=1

for(int j=1;j<=i;j++)

fact*=j;

s+=fact

}

System.out.println("the value of sum series is :"+s);

}

}

Answered by mayank2007raj
2

import java.util.Scanner;

public class Sum series

{

public static void main (String args[])

{

Scanner sc = new Scanner(System.in);

System.out.println("Enter a number");

int n = sc.nextInt();

int s =0;

int p;

for(int i = 1; I<=n;i++)

{

p=1;

for(int j =1;j<=I;j++)

p=p*j;

s=s+p;

}

System.out.println("The sum of series is :" +s);

}

}

Similar questions