summaryrefslogtreecommitdiff
path: root/fib.c
diff options
context:
space:
mode:
Diffstat (limited to 'fib.c')
-rw-r--r--fib.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/fib.c b/fib.c
new file mode 100644
index 0000000..7525d1b
--- /dev/null
+++ b/fib.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <assert.h>
+
+int fib(int n)
+{
+ if (n == 1) {
+ return 0;
+ }
+
+ if (n == 2 || n == 3) {
+ return 1;
+ }
+
+ return 2;
+}
+
+int main(int argc, char *argv[])
+{
+ assert(fib(1) == 0);
+ assert(fib(2) == 1);
+ assert(fib(3) == 1);
+ assert(fib(4) == 2);
+
+
+ printf("YAY!\n");
+ return 0;
+}