Guest User

Untitled

a guest
Oct 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <iostream> //saidow
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int n;
  7. cout<<"Fibonacci hesaplamak istediginiz sayiyi giriniz: "<<endl;
  8. cin>>n;
  9. int a=1;
  10. int b=1;
  11. cout<<"Fibonacci Serisi = "<<endl;
  12. if(n==0)
  13. cout<<"0 degerinden farkli sayi gir."<<endl;
  14. else if(n==1)
  15. cout<<1<<endl;
  16. else{
  17. for(int i=0; i<n-2; i++)
  18. {
  19. cout<<a<<endl<<b<<endl;
  20. int c = a+b;
  21. a=b;
  22. b=c;
  23. cout<<c<<endl;
  24. }
  25. return 0;
  26. }
  27. } //saidow
Add Comment
Please, Sign In to add comment