projects
/
libfirm
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
fixed comments
[libfirm]
/
ir
/
be
/
test
/
fib_iter.c
1
unsigned long fib_iter(int n) {
2
unsigned long a = 1, b = 1, c, i;
3
4
if (n < 2)
5
return 1;
6
7
for (i = 1; i < n; i++) {
8
c = a + b;
9
a = b;
10
b = c;
11
}
12
13
return c;
14
}
15
16
int main(int argc, char *argv[]) {
17
int i, n = 10;
18
19
if (argc > 1) {
20
n = atoi(argv[1]);
21
}
22
23
for (i = 0; i <= n; i++)
24
printf("fib(%d) = %lu\n", i, fib_iter(i));
25
26
return 0;
27
}