![Quote](https://cboard.cprogramming.com/images/misc/quote_icon.png)
Originally Posted by
cph
actually I've tried that (slow) recursive fibonacci algorithm (and the problem is it's too slow).
Oh malarky
Code:
#include <stdio.h>
int main () {
int a=0, b=1, n=a+b,i,ii;
puts("Number of iterations");
scanf("%d",&ii);
printf("%d %d ",a,b);
for (i=0;i<ii;i++) {
n=a+b;
printf("%d ",n);
a=b;b=n;
}
}
I don't know much math, so I'd be really interested to read how you could make this computation "more efficient".
[edit] i guess this is actually iterative, and not recursive