summaryrefslogtreecommitdiff
path: root/test/c/fib.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/c/fib.c')
-rw-r--r--test/c/fib.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/c/fib.c b/test/c/fib.c
index 34e7baa..763fee8 100644
--- a/test/c/fib.c
+++ b/test/c/fib.c
@@ -1,3 +1,6 @@
+#include <stdlib.h>
+#include <stdio.h>
+
int fib(int n)
{
if (n < 2)
@@ -5,3 +8,12 @@ int fib(int n)
else
return fib(n-1) + fib(n-2);
}
+
+int main(int argc, char ** argv)
+{
+ int n, r;
+ if (argc >= 2) n = atoi(argv[1]); else n = 30;
+ r = fib(n);
+ printf("fib(%d) = %d\n", n, r);
+ return 0;
+}