Computer Science, asked by rajdeepsurroy950, 3 months ago

1+2!+3!+4!......n series in java

Answers

Answered by BrainlyProgrammer
7

Series :-

  • 1!+2!+3!....Nth term

Code Language :-

  • Java

This is a very simple question here is an approach

Code :-

package Coder;

import java.util.*;

public class FactSer{

public static void main (String ar []){

Scanner sc=new Scanner (System.in);

System.out.println("Enter number of terms");

int n=sc.nextInt();

int s=0,f=1;

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

f=1;

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

f *=i;

}

s+=f;

}

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

}

}

Variable Description:-

  • n:- to Accept number as input from the user.
  • s:- to calculate sum of factorial
  • f:- to calculate factorial of a number
  • I:- loop variable
  • j:- loop variable

•Output Attached.

Attachments:

anindyaadhikari13: This can be solved using 1 loop also.
Similar questions