fibonacci test program
authorMatthias Braun <matze@braunis.de>
Mon, 12 Jun 2006 08:27:28 +0000 (08:27 +0000)
committerMatthias Braun <matze@braunis.de>
Mon, 12 Jun 2006 08:27:28 +0000 (08:27 +0000)
ir/be/test/fib.c [new file with mode: 0644]

diff --git a/ir/be/test/fib.c b/ir/be/test/fib.c
new file mode 100644 (file)
index 0000000..a11e94f
--- /dev/null
@@ -0,0 +1,21 @@
+#include <stdio.h>
+
+unsigned fib(unsigned n)
+{
+    if(n == 0)
+        return 0;
+    if(n == 1)
+        return 1;
+
+    return fib(n-1) + fib(n-2);
+}
+
+int main(int argc, char** argv) {
+    unsigned n = 8;
+    if(argc > 1)
+        n = (unsigned) atoi(argv[1]);
+
+    printf("Fib %u: %u\n", n, fib(n));
+
+    return 0;
+}