CodePudding user response:
In this first write each item, molecule expressed with variable, fixed here is 1 need not variable, the denominator expressed in a variable, behind a denominator is equal to the front of a variable (I) the denominator by cycle between adjacent two (regular), add up all the can use cycle,CodePudding user response:
The key is to find a rule, both before and after the differences and the relationship between the loop variable, how to use each variables and circulation, pay attention to the data type is ok,CodePudding user response:
If does not require high precision is simple:Double f (int n)
{
If (n & lt; 1) return 0;
Double r=1, fn=1;
For (int I=2; I & lt;=n; I++) r +=fn=fn/I;
Return r;
}
High-precision GMP library can be used
CodePudding user response:
Thank you