aboutsummaryrefslogtreecommitdiff
path: root/fibo.lang
diff options
context:
space:
mode:
Diffstat (limited to 'fibo.lang')
-rw-r--r--fibo.lang31
1 files changed, 0 insertions, 31 deletions
diff --git a/fibo.lang b/fibo.lang
deleted file mode 100644
index e1a7a4a..0000000
--- a/fibo.lang
+++ /dev/null
@@ -1,31 +0,0 @@
-func printnum(int n) {
- if (n == 0) {putc('0'); return;}
- if (n < 0) {putc('-'); n = -n;}
- while (n > 0) {
- putc('0' + char(n % 10));
- n = n / 10;
- }
-}
-
-func int fibo(int n) {
- int a := 0;
- int b := 1;
- int i := 0;
- while (i < n) {
- int c := a + b;
- a = b;
- b = c;
- i = i + 1;
- }
- return b;
-}
-
-func int main() {
- int i := 0;
- while (i <= 20) {
- printnum(fibo(i));
- putc('\n');
- i = i + 1;
- }
- return 0;
-}