fibonaci

#include <iostream> using namespace std; int fibonaci(int s); int fibonaci(int s) { if(s==0||s==1) return 1; else return (fibonaci(s-2)+fibonaci(s-1)); } int main() { cout<<"ham tim day so fibonaci"<<endl; int n,i; cout<<"nhap vao mot so nguyen: "; cin>>n; cout<<" so fibonaci thu "<<n<<" la: "<<fibonaci(n)<<endl; cout<<"day fibonaci la: "; for(i=0; i<=n; i++) { cout<<" "<<fibonaci(i); } return 0; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.