You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sledge/runtime/tests/fibonacci2/main.c

31 lines
500 B

#include <stdio.h>
#include <stdlib.h>
unsigned long int
fib(unsigned long int n)
{
if (n <= 1) return n;
return fib(n - 1) + fib(n - 2);
}
int
main(int argc, char **argv)
{
unsigned long n = 0;
scanf("%lu", &n);
//size_t rd = read(0, recv_buf, 1000*1024);
//if (rd <= 0) return -1;
// unsigned long long st = get_time(), en;
//r = fib(30);
// en = get_time();
for (int i = 0; i < 3; i++)
{
n = fib(n);
}
printf("%lu\n", n);
return 0;
}