HNDIT
Tuesday, December 18, 2012
FIBONACCI NUMBER SERIES PROGRAMME 2 IN C++
#include <iostream.h>
int fib(int n)
{
if(1 == n || 2 == n)
{
return 1;
}
else
{
return fib(n-1) + fib(n-2);
}
}
void main()
{
for(int i=1; i<=10; i++)
{
cout << fib(i) << endl;
}
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment