blob: e1a7a4a09da213caa439c47b876bed6476e99e87 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
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;
}
|