From f5c4671bfbad96bf346bd7e9a21fc4317b4959df Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Sat, 3 Dec 2022 17:00:20 +0530 Subject: Adds most of the tools --- tcc/examples/fib.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tcc/examples/fib.c (limited to 'tcc/examples/fib.c') diff --git a/tcc/examples/fib.c b/tcc/examples/fib.c new file mode 100644 index 0000000..8da26bc --- /dev/null +++ b/tcc/examples/fib.c @@ -0,0 +1,24 @@ +#include +#include // atoi() + +int fib(n) +{ + if (n <= 2) + return 1; + else + return fib(n-1) + fib(n-2); +} + +int main(int argc, char **argv) +{ + int n; + if (argc < 2) { + printf("usage: fib n\n" + "Compute nth Fibonacci number\n"); + return 1; + } + + n = atoi(argv[1]); + printf("fib(%d) = %d\n", n, fib(n)); + return 0; +} -- cgit v1.2.3