92c5cd59f5
- Create stdlib/Std/Io.bux with extern func declarations
- Rename C shim functions to short names (PrintLine, PrintInt, etc.)
- Update all 9 examples to use import Std::Io::{PrintLine, PrintInt};
- Remove manual extern func Std_Io_* declarations from examples
25 lines
446 B
Plaintext
25 lines
446 B
Plaintext
// Fibonacci - Recursive function with while loop
|
|
import Std::Io::{PrintLine, PrintInt};
|
|
|
|
|
|
func Fibonacci(n: int) -> int {
|
|
if n <= 1 {
|
|
return n;
|
|
}
|
|
return Fibonacci(n - 1) + Fibonacci(n - 2);
|
|
}
|
|
|
|
func Main() -> int {
|
|
PrintLine("Fibonacci sequence:");
|
|
|
|
var i: int = 0;
|
|
while i < 10 {
|
|
let fib: int = Fibonacci(i);
|
|
PrintInt(fib);
|
|
PrintLine("");
|
|
i = i + 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|