37 lines
483 B
Fortran
37 lines
483 B
Fortran
/**
|
|
* Constants
|
|
*/
|
|
const str nl = "\n";
|
|
|
|
plex Terminal {
|
|
nat handle;
|
|
|
|
init() {
|
|
handle = open("/dev/term/0", 0);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Main function
|
|
*/
|
|
function main() {
|
|
pln(fib(35).str);
|
|
}
|
|
|
|
/**
|
|
* Recursively calculate fibonacci
|
|
*/
|
|
function fib(int n) int {
|
|
if (n < 2) return n;
|
|
return fib(n - 2) + fib(n - 1);
|
|
}
|
|
|
|
/**
|
|
* Print with a newline
|
|
*/
|
|
function pln(str message) {
|
|
Terminal term();
|
|
write(term, message, message.length);
|
|
write(term, nl, nl.length);
|
|
}
|