-(void)Fibonacci
{
int range = 15;
NSMutableArray* arr = [[NSMutableArray alloc]init];
for (int k =0; k< range; k++)
{
if(k<2)
{
[arr addObject:[NSString stringWithFormat:@"%d",k]];
continue;
}
else
{
int fib = [[arr objectAtIndex:k-2] intValue] + [[arr objectAtIndex:k-1] intValue];
[arr addObject:[NSString stringWithFormat:@"%d",fib]];
}
}
NSLog(@"%@",arr);
}
Output : 2014-03-27 17:31:05.284 Sqlite3[2844:70b] (
0,
1,
1,
2,
3,
5,
8,
13,
21,
34,
55,
89,
144,
233,
377
)