fork download
  1. /******************************************************************************
  2. Homework 1F - Mystery Sum
  3. Jie Dai
  4. 2/1
  5.  
  6. *******************************************************************************/
  7.  
  8. #include <iostream>
  9. #include <iomanip>
  10. #include <cmath>
  11.  
  12. using namespace std;
  13.  
  14. int main()
  15. {
  16. // --------------------- Part 1 --------------------
  17. int x;
  18. cout << "Please enter a positive integer: \n";
  19. cin >> x;
  20. cout << x;
  21.  
  22. // --------------------- Part 2 --------------------
  23. float sum1 = 0;
  24. for (float i = 1; i <= x; i++){
  25. sum1 += 1 / pow(sum1,2);
  26. }
  27.  
  28. cout<< sum1;
  29.  
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0.01s 5528KB
stdin
Standard input is empty
stdout
Please enter a positive integer: 
32765inf