Practice 5
Main | Review of Operators | Mathematical Functions | Practice 5 | Solution 5 | HTML Forms | PHP Forms | Practice 6 | Solution 6 | PHP and E-mail | Practice 7 | Solution 7 In math we can take the factorial of an integer by taking the product of its preceding positive integers. So: 1! = 1 2! = 2 * 1 = 2 3! = 3 * 2 * 1 = 6 4! = 4 * 3 * 2 * 1 = 24 5! = 5 * 4 * 3 * 2 * 1 = 120 We could change the notation of the above and replace the exclamation point (!) with a function called factorial such that: factorial(5) = 5! and thus: factorial(5) = 5 * 4 * 3 * 2 * 1 = 120 To complete this exercise you must:
For extra credit make a recursive version of your factorial function. Use the following definition:
HINTS: If you are not sure where to start here are some hints for the exercise (these hints are not for the extra credit).
jfulton [at] member.fsf.org
|