A125503 Smallest number k such that the numerator of the generalized harmonic number H(k,n) = Sum_{i=1..k} 1/i^n is a prime.
2, 2, 3, 2, 23, 73, 15, 2, 3, 5, 13, 57, 3, 171, 5, 2, 21, 7, 55, 8902, 26, 1298, 115, 139, 3, 2019, 3, 4, 3, 15, 56, 177
Offset: 1
Links
- Eric Weisstein's World of Mathematics, Harmonic Number
Programs
-
Mathematica
Do[n = 1; f = 0; While[Not[PrimeQ[Numerator[f]]], f = f + 1/n^x; n++ ]; Print[{x, n - 1}], {x, 1, 25}] (* Alexander Adamchuk, Apr 18 2010 *)
-
PARI
a(n) = my(k=1); while (!ispseudoprime(numerator(sum(i=1, k, 1/i^n))), k++); k; \\ Michel Marcus, Jun 04 2022
-
Python
from sympy import isprime from fractions import Fraction def a(n): Hkn, k = Fraction(1, 1), 1 while not isprime(Hkn.numerator): k += 1 Hkn += Fraction(1, k**n) return k print([a(n) for n in range(1, 20)]) # Michael S. Branicky, Jun 11 2022
Extensions
a(22)-a(25) from Alexander Adamchuk, Apr 18 2010
a(26)-a(32) from Alexander Adamchuk, Apr 26 2010
Incorrect a(20) removed by Michael S. Branicky, Jun 25 2022
a(20) = 8902 from Michael S. Branicky, Jun 12 2023
Comments