Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- run this with
- clang fib.c
- (or gcc fib.c)
- time ./a.out
- */
- #include <stdio.h>
- unsigned int fib(int n) {
- if (n <= 2) return 1;
- else return fib(n - 2) + fib(n - 1);
- }
- int main() {
- printf("%u", fib(40));
- }
- /*
- run this with
- time node ./fib.js
- */
- function fib(n) {
- if (n <= 2) return 1;
- else return fib(n - 2) + fib(n - 1);
- }
- console.log(fib(40));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement