Results 1 to 1 of 1

Thread: Recursive functions

  1. #1
    Acolyte ExcelStarter's Avatar
    Join Date
    Jan 2018
    Posts
    25
    Articles
    0
    Excel Version
    2016

    Recursive functions



    Register for a FREE account, and/
    or Log in to avoid these ads!

    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 by ExcelStarter; 2020-09-21 at 10:16 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •