GLaDOS
  • Home
  • 🌴Introduction
    • Installation
    • Basic Code example
    • Syntax Overview
  • 🤖Developpers
    • Parsing
    • Verbose Mode
  • ✨Features
    • Types
    • Operators
    • Lists
    • Includes
    • Syntactic Sugar
    • Loops
    • Conditions
    • Internal Functions
    • Recursivity
    • Prototypes
    • Error handling
    • Comments
    • Scopes
  • 📚Libraries
    • Mathematics
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Features

Recursivity

PreviousInternal FunctionsNextPrototypes

Last updated 1 year ago

Was this helpful?

GoMelan supports recursivity.

fn factorial(n: Int) -> Int
{
    if (n <= 1) {
        return 1;
    } else {
        return n * factorial(n - 1);
    }
}

fn main() -> Int
{
    return factorial(5);
}

Output:

120
  1. Declare the factorial function.

  2. Recursively calculating the factorial of n.

  3. Call the factorial function in main with n=5.

For more information on recursivity, please visit .

✨
this page