#import <Foundation/Foundation.h>
int fibonacci(int n)
{
if(n<=2)
return(1);
return fibonacci(n-1) + fibonacci(n-2);
}
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int i;
for(i=1;i<=8;i++)
{
int fib=fibonacci(i);
NSLog (@"%d,",fib);
}
[pool drain];
return 0;
}
int fibonacci(int n)
{
if(n<=2)
return(1);
return fibonacci(n-1) + fibonacci(n-2);
}
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int i;
for(i=1;i<=8;i++)
{
int fib=fibonacci(i);
NSLog (@"%d,",fib);
}
[pool drain];
return 0;
}
No comments:
Post a Comment