Maybe you should specify the required precision in the problem description.
OK, I added a sentence, thanks.
different matlab fnction used to solve this problem
lol ! need a translator for this solution!
This solution should provide minimal rounding error since it's done in an essentially symbolic domain and then evaluated at the very end, but it doesn't satisfy the test cases. *sigh*
The sequence is strictly positive. (Not easy to see, but true). If your pn's get negative at some higher n, you still have the roundoff problem. It would be indeed avoided if the integer calculation within the loop was exact, but the numbers quickly become larger than the 48bit mantissa of a double.
DNA N-Gram Distribution
Better bullseye matrix
Sum of first n terms of a harmonic progression
Implement a counter
How long do each of the stages of the rocket take to burn?
Differential equations I
Find the treasures in MATLAB Central and discover how the community can help you!
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office