[
Home
|
Training
|
Problems
|
Contests
|
C Language
]
[
Login
|
Register
]
New post
Show post
Search forum
Read post
what's wrong with my answer,who can tell me
[
Topic
] 2009-11-22 15:26:54
liuxiaochun
#include<iostream>
using namespace std;
int Fibonacci(int n);
int main()
{
int num;
while(cin>>num)
{
if(num>40||num<2)
break;
else
cout<<"The Fibonacci Number for "<<num<<" is "<<Fibonacci(num)<<endl;
}
return 0;
}
int Fibonacci(int n)
{
if(n==0)
return 0;
else
if(n==1)return 1;
else
return Fibonacci(n-1)+Fibonacci(n-2);
}
Reply
Title
Message
(64K)
University of Science and Technology of China
Online Judge for ACM/ICPC
Processed in 2.6ms with 2 query(s).