fork(1) download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main() {
  6. int n;
  7. cin >> n;
  8. int a, b, c, d, k;
  9. a = 1;
  10. b = 1;
  11. c = 2;
  12. bool x;
  13. int counter = 0;
  14. while (counter < n){
  15. x = true;
  16. c = a + b;
  17. a = b;
  18. b = c;
  19. for (int j = 2; j <= sqrt(c) && x; j++) {
  20. if((c%j) == 0){
  21. x = false;
  22. }
  23. }
  24. if (x){
  25. counter ++;
  26. }
  27. }
  28. cout << c;
  29. return 0;
  30. }
Success #stdin #stdout 0s 3416KB
stdin
5
stdout
89