| www.richandlucy.com | © www.richandlucy.com |
|
Home
|
Photos
|
Stuff
|
Forum
|
|
|
> Stuff > Lucy's Portfolio! > Javascript Example 9
For any given number n, calculate n! or n factorial. n! = n*(n-1)*(n-2)*…*2*1=n*(n-1)! Etc... Create a table to input the value of n, to display the answer and for a button to start the calculation. A function will be required which calls itself (this is called recursion) e.g. if your function is called factorial(n) there will be a line in it that calls n*factorial(n-1). You can see the page created here
|
||||||||||||||
|
||||||||||||||