Advertisement
Faldi767

Fibonaci

Jan 22nd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <stdio.h>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. int main(int argc, char** argv) {
  8. int a=1, b=0, c, step;
  9. while(c<20) {
  10. if(step == 0) {
  11. cout << a << " ";
  12. step++;
  13. } else {
  14. c = a+b;
  15. b = a;
  16. a = c;
  17. cout << c << " ";
  18. }
  19. }
  20. cout << endl;
  21. return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement