write a Java program to find the sum of series.
1!/1 +2!/2 +3!/3 + n!/n
please give answers fast it's urgent..
Answers
Answer:
Program:-
//Program using Scanner class
import java.util.*;
public class Brainly_Answer
{
public static void main(String args[ ])
{
Scanner in=new Scanner(System.in);
int i,j,n;
double s=0;
System.out.println("Enter limit:");
n=in.nextInt();
for(i=1;i<=n;i++)
{
int fact=1;
for(j=1;j<=i;j++)
{
fact=fact*j;
}
s=s+fact/(double)i;
}
System.out.println("The sum of the given series="+s);
}
}
- The first photo is the program.
- The second photo is the input i.e 3. I entered three so that you can also calculate it easily by checking.(1+1+2=4)
- The third photo is the output that I have checked it's right.
- The fourth photo is the input ,I entered 5
- The fifth photo is the output that I also checked(4+6+24).
Sorry I can't type 'f' so I changed it as 'fact' otherwise in brainly it's showing error.
Explanation:
Answer:
Program:-
//Program using Scanner class
import java.util.*;
public class Brainly_Answer
{
public static void main(String args[ ])
{
Scanner in=new Scanner(System.in);
int i,j,n;
double s=0;
System.out.println("Enter limit:");
n=in.nextInt();
for(i=1;i<=n;i++)
{
int fact=1;
for(j=1;j<=i;j++)
{
fact=fact*j;
}
s=s+fact/(double)i;
}
System.out.println("The sum of the given series="+s);
}
}
The first photo is the program.
The second photo is the input i.e 3. I entered three so that you can also calculate it easily by checking.(1+1+2=4)
The third photo is the output that I have checked it's right.
The fourth photo is the input ,I entered 5
The fifth photo is the output that I also checked(4+6+24).
Sorry I can't type 'f' so I changed it as 'fact' otherwise in brainly it's showing error.
Explanation:
Answer:
Program:-
//Program using Scanner class
import java.util.*;
public class Brainly_Answer
{
public static void main(String args[ ])
{
Scanner in=new Scanner(System.in);
int i,j,n;
double s=0;
System.out.println("Enter limit:");
n=in.nextInt();
for(i=1;i<=n;i++)
{
int fact=1;
for(j=1;j<=i;j++)
{
fact=fact*j;
}
s=s+fact/(double)i;
}
System.out.println("The sum of the given series="+s);
}
}
The first photo is the program.
The second photo is the input i.e 3. I entered three so that you can also calculate it easily by checking.(1+1+2=4)
The third photo is the output that I have checked it's right.
The fourth photo is the input ,I entered 5
The fifth photo is the output that I also checked(4+6+24).
Sorry I can't type 'f' so I changed it as 'fact' otherwise in brainly it's showing error.