Advertisement
am1x

sumgammaadd001

Feb 3rd, 2022
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <quadmath.h>
  2. #include <stdio.h>
  3. #include <assert.h>
  4. #include <inttypes.h>
  5. #include <math.h>
  6.  
  7. typedef __float128 real;
  8.  
  9. int main()
  10. {
  11. uint64_t n = 100000000;
  12. real s = 0;
  13. for (uint64_t i = 2; i <= n; i++) {
  14. real x = i;
  15. real y = expm1q(logq(x) / x) / x;
  16. s += y;
  17. }
  18.  
  19. {
  20. real x = n + 0.5q;
  21. real lx = logq(x);
  22. real y1 = (lx + 1) / x;
  23. real y2 = (2 * lx * (lx + 1) + 1) / (4 * x * x);
  24. s += y1;
  25. s += 0.5 * y2;
  26. }
  27.  
  28. printf("n=%lu, %.36Qf\n", n, s);
  29. return 0;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement