fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. double an=0,a=2;
  7. cin >> n;
  8. for (int k=0;k<= n; k++) {
  9. an= 2 + 1 / a;
  10. a = an;
  11. cout << an<<endl;
  12. }
  13.  
  14. return 0;
  15. }
Success #stdin #stdout 0s 5312KB
stdin
5
stdout
2.5
2.4
2.41667
2.41379
2.41429
2.4142