fork download
  1. #include <iostream>
  2.  
  3. long double hs(int n) {
  4. long double r = 0.0;
  5. for (int i = 1; i <= n; ++i) {
  6. r += 1 / (long double)i;
  7. }
  8. return r;
  9. }
  10.  
  11. int main() {
  12. std::cout << hs(3);
  13. return 0;
  14. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
1.83333