History

fib fix (grischka)

bellard committed 21 years ago

Commit 6144d431 parent c897c521 file · +23 −23Browse files

Unified · Split

win32/examples/fib.c+23−23
@@ -1,23 +1,23 @@
1#include <stdio.h>1#include <stdio.h>
2 2
3int fib(n)3int fib(n)
4{4{
5 if (n <= 2)5 if (n <= 2)
6 return 1;6 return 1;
7 else7 else
8 return fib(n-1) + fib(n-2);8 return fib(n-1) + fib(n-2);
9}9}
10 10
11int main(int argc, char **argv) 11int main(int argc, char **argv)
12{12{
13 int n;13 int n;
14 if (argc < 2) {14 if (argc < 2) {
15 printf("usage: fib n\n"15 printf("usage: fib n\n"
16 "Compute nth Fibonacci number\n");16 "Compute nth Fibonacci number\n");
17 return 1;17 return 1;
18 }18 }
19 19
20 n = atoi(argv[1]);20 n = atoi(argv[1]);
21 printf("fib(%d) = %d\n", n, fib(n, 2));21 printf("fib(%d) = %d\n", n, fib(n));
22 return 0;22 return 0;
23}23}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t