Home > Back-end >  Please will help
Please will help

Time:06-05

Write a program to calculate s=1 + 1/2! + a third! + a quarter! +... 1/n! The value of the (n by keyboard input a value),

CodePudding user response:

Here to consider data types, it is recommended to use double
Factorial calculation can be used the next value multiplied above a factorial
Double s=0, a=1;
for(int i=1; i<=n; I++)
{
A=a * I;
S +=1.0/a;
}
Cout & lt; CodePudding user response:

I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html
  • Related