am1x icon

sumgammaadd001

am1x | PRO | 02/03/22 02:49:31 PM UTC | 0 ⭐ | 594 👁️ | Never ⏰ | []
text |

500 B

|

None

|

0 👍

/

0 👎

#include <quadmath.h>
#include <stdio.h>
#include <assert.h>
#include <inttypes.h>
#include <math.h>
 typedef __float128 real;
 int main()
{
	uint64_t n = 100000000;
	real s = 0;
	for (uint64_t i = 2; i <= n; i++) {
		real x = i;
		real y = expm1q(logq(x) / x) / x;
		s += y;
	}
 	{
		real x = n + 0.5q;
		real lx = logq(x);
		real y1 = (lx + 1) / x;
		real y2 = (2 * lx * (lx + 1) + 1) / (4 * x * x);
		s += y1;
		s += 0.5 * y2;
	}
 	printf("n=%lu, %.36Qf\n", n, s);
	return 0;
}
 

Comments