Checked: FNXBasic works with recursive functions !
Posted: Tue May 06, 2008 8:57 am
I was interested if FNXBasic is working with recursive functions.
So I`have written a small program to calculate the faculty of numbers within a recursive function.
(For those people who don`t know that:
? A recursive function is a function that calls itself!)
`========================================
`begin of code
? ?Dim wert as LONG
? ?wert = FAC(3)
? ?showmessage "The result is: " + str$(wert)
? ? FUNCTION FAC(value AS LONG) AS LONG
? ? ? ? result = 1
? ? ?? ?IF value > 1 THEN result = value * ?FAC(value - 1)
? ? END FUNCTION
`end of code?
`========================================
I think this information should also be included in the help !
Because it is important: you can simplify your code.
To calculate the faculty with a nonrecursive function you need much more lines!
I hope my posts will improve the traffic in this sleepy forum a little bit! ? ;)
Hi to all
Fazer
So I`have written a small program to calculate the faculty of numbers within a recursive function.
(For those people who don`t know that:
? A recursive function is a function that calls itself!)
`========================================
`begin of code
? ?Dim wert as LONG
? ?wert = FAC(3)
? ?showmessage "The result is: " + str$(wert)
? ? FUNCTION FAC(value AS LONG) AS LONG
? ? ? ? result = 1
? ? ?? ?IF value > 1 THEN result = value * ?FAC(value - 1)
? ? END FUNCTION
`end of code?
`========================================
I think this information should also be included in the help !
Because it is important: you can simplify your code.
To calculate the faculty with a nonrecursive function you need much more lines!
I hope my posts will improve the traffic in this sleepy forum a little bit! ? ;)
Hi to all
Fazer