Recursive functions

ExcelStarter

New member
Joined
Jan 23, 2018
Messages
27
Reaction score
0
Points
0
Excel Version(s)
2016
let
Factorial = (x) => if x = 0 then 1 else x * @Factorial(x - 1),
Result = Factorial(3) // 6
in
Result

--> 6


let
Factorial = (x) => if x = 0 then 1 else Factorial2(x),
Factorial2 = (x) => x * Factorial(x - 1),
Result = Factorial(3) // 6
in
Result

--> Expression.Error: A cyclic reference was encountered during evaluation.

Why am I getting the error?
-------------------------------------------------------------------------------------
[
Factorial = (x) => if x = 0 then 1 else Factorial2(x),
Factorial2 = (x) => x * Factorial(x - 1),
Result = Factorial(3) // 6
]

--> Why is there no error?
 
Last edited:
Back
Top