fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int licznik,pobrana,pom,a,b,c;
  7.  
  8. a = 0;
  9. b = 1;
  10.  
  11. licznik = 0;
  12.  
  13. cout << "Podaj liczbe: ";
  14. cin >> pobrana;
  15.  
  16. while(licznik != pobrana-2)
  17. {
  18. licznik++;
  19. c = a+b;
  20.  
  21. pom = a;
  22. a = b;
  23. b = pom+b;
  24.  
  25.  
  26. }
  27.  
  28. cout << "F(" << pobrana << ")=" << c;
  29.  
  30. }
  31.  
Success #stdin #stdout 0.01s 2728KB
stdin
5
stdout
Podaj liczbe: F(5)=3