double countdivisors(BigInt n, BigInt k){ if (k == 0) return 1; if (k == 1) return n - 1; BigInt t = 0; for (BigInt i = 2; i <= n; i++) t += countdivisors( n / i, k - 1 ); return t; }
BigInt countprimes1( BigInt n){ double t = 0.0; for (BigInt j = 1; j < log((double)n) / log(2.0); j++) for (BigInt k = 1; k < log( pow( n, 1.0 / j ) ) / log(2.0); k++) t += pow( -1.0, (double)k+1 ) * countdivisors(pow( n, 1.0 / j ), k) / k / j * mu[j]; return (t+.1); }
int main(int argc, char **argv) { long long i = 0, triangle = 0, count = -1; while (count < 500) { count = countdivisors(triangle += ++i); if (count > 200) printf("i: %lld\ttriangle: %lld\tcount: %lld\n", i, triangle, count); } printf("number: %lld - count: %lld\n", triangle, count); return 0; }