A373893 a(n) is the length of the simple continued fraction for the n-th alternating harmonic number.
0, 1, 2, 4, 7, 7, 5, 9, 8, 12, 9, 12, 11, 12, 13, 12, 18, 12, 17, 15, 15, 15, 19, 21, 18, 13, 21, 23, 25, 23, 26, 32, 28, 25, 24, 24, 31, 32, 33, 36, 41, 38, 38, 37, 44, 41, 37, 39, 47, 48, 42, 43, 43, 44, 46, 42, 44, 51, 45, 49, 52, 53, 62, 50, 57, 48, 55, 60, 52, 58, 70, 58, 60, 73, 67
Offset: 1
Keywords
Examples
Sum_{k=1..7} (-1)^(k+1)/k = 319/420 = 1/(1 + 1/(3 + 1/(6 + 1/(3 + 1/5)))), so a(7) = 5.
Programs
-
Mathematica
Table[Length[ContinuedFraction[Sum[(-1)^(k + 1)/k, {k, 1, n}]]] - 1, {n, 1, 75}]
-
Python
from fractions import Fraction from sympy.ntheory.continued_fraction import continued_fraction def A373893(n): return len(continued_fraction(sum(Fraction(1 if k&1 else -1,k) for k in range(1,n+1))))-1 # Chai Wah Wu, Jun 27 2024
Comments