Problem 45770. Approximate functions 1 (★★★)
Compute the following sum for any given x and positive integer n.
Here m! denotes the factorial of m, which the product of all natural numbers upto m. Thus,
2! = 1x2 = 2
3! = 1x2x3 = 6
5! = 1x2x3x4x5 = 120
Avoid using for/while loops.
Solution Stats
Problem Comments
-
2 Comments
Dyuman Joshi
on 27 Nov 2020
You should use tolerance based test-suites and not isequal while dealing with floats.
goc3
on 30 Nov 2020
A tolerance has been added to the test suite.
Solution Comments
Show commentsProblem Recent Solvers44
Suggested Problems
-
Calculate the area of a triangle between three points
2709 Solvers
-
1440 Solvers
-
Matlab Basics II - Max & Index of Max
243 Solvers
-
217 Solvers
-
Generate n equally spaced "intervals" between -x and x (★)
109 Solvers
More from this Author52
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!