Hii Guys ..Can you all please help me with this Java Program??
1/2! + 3/4! + 5/6! ..n terms...
Answers
Answered by
1
Answer:
#import java.io.*
public int factorial(int n)
{
if(n==1)
return 1
else
return n*factorial(n-1)
}
public void main()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in))
System.out.println("Enter n:")
int no=Integer.parseInt(br.readLine())
int sum=0
for(int i=1,i<=n,i++)
{
ifac=factorial(i)
sum=(i%2==0)?(sum-ifac):(sum+ifac)
}
System.out.println(sum)
}
Similar questions
Computer Science,
4 hours ago
English,
4 hours ago
Chemistry,
7 hours ago
English,
7 hours ago
Math,
8 months ago
Social Sciences,
8 months ago