def factorial(value: int): int {
if (value <= 1) { return 1; };
return value * factorial(value - 1);
}
def main(): int {
return factorial(5);
}عرف مضروب(القيمة: عدد): عدد {
إذا (القيمة <= 1) { أرجع 1; };
أرجع القيمة * مضروب(القيمة - 1);
}
عرف الرئيسية(): عدد {
أرجع مضروب(5);
}
Run it
With the interpreter, without compiling:
./build/sultanc run examples/en/functions/recursion.snOr compile it to an executable:
./build/sultanc examples/en/functions/recursion.sn -o build/example && ./build/example