Search Tutorials
Instead of the standard use of recursive functions (where a function calls itself over and over) this one simply loops until it reaches one and multiplies it to the total. Here's the basic source code: If ( n > 0) Set Variable: "i" = 1 Set Variable: "total" = n Loop While (i<n) Set Variable: "total" = total*(n-i) Set Variable: "i" = i+1 End Loop Else If (n=0) Set Variable: "total" = 1 End If If (n<0) Set Variable: "total" = "Negative Num" End If It first checks to see if n (the input number) is positive then it just decreases the number to be multiplied. If it's zero then the answer is automatically 1. It prints an error message. To use in your own apps, either copy the above script into the appropriate frame or you can check out the button action in my .fla. Good luck and enjoy!
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|