53b43b0f79
Ship the QUALITY_PLAN stretch from ownership through ecosystem: C.1 lifetime elision (bootstrap + selfhost), bux fmt/test/doc CI hooks, stdlib goldens, package registry (bux search/add), and LSP 0.4 position-sensitive locals with inferred let types. Full-tree format pass plus Map/Set remove double-free fix.
24 lines
457 B
Plaintext
24 lines
457 B
Plaintext
// Factorial - Recursive function
|
|
import Std::Io::{PrintLine};
|
|
import Std::Fmt::{Fmt_Fmt2};
|
|
|
|
func Factorial(n: int) -> int {
|
|
if n <= 1 {
|
|
return 1;
|
|
}
|
|
return n * Factorial(n - 1);
|
|
}
|
|
|
|
func Main() -> int {
|
|
PrintLine("Factorials:");
|
|
|
|
var i: int = 1;
|
|
while i <= 10 {
|
|
let fact: int = Factorial(i);
|
|
PrintLine(Fmt_Fmt2("{0}! = {1}", String_FromInt(i), String_FromInt(fact)));
|
|
i = i + 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|