OFFSET
1,2
COMMENTS
The mass of a rational k/n is the sum of the partial quotients in the continued fraction for k/n. Alternatively, it is the number of steps in the "subtractive algorithm" to compute gcd(k,n).
LINKS
Amiram Eldar, Table of n, a(n) for n = 1..10000
Christoph Aistleitner, Bence Borda, and Manuel Hauke, On the distribution of partial quotients of reduced fractions with fixed denominator, ArXiv preprint arXiv:2210.14095 [math.NT], 2022-2023.
Bernhard Liehl, Über die Teilnenner endlicher Kettenbrüche, Arch. Math. (Basel), 40 (1983), 139-147.
A. A. Panov, The mean for a sum of elements in a class of finite continued fractions (in Russian), Mat. Zametki 32 (1982), 593-600, 747; English version, Mathematical Notes of the Academy of Sciences of the USSR 32 (1982), 781-785.
Maurice Shrader-Frechette, Modified Farey sequences and continued fractions, Math. Mag., 54 (1981), 60-63.
FORMULA
Panov (1982) and Liehl (1983) independently proved that a(n) is asymptotically (6/Pi)^2*n*(log n)^2.
EXAMPLE
For n = 4 the two numbers relatively prime to n are 1 and 3; 1/4 = [0,4] and 3/4 = [0,1,3]. So the sum of all these is a(3) = 8.
MAPLE
a:= n-> add(`if`(igcd(n, k)=1, add(i, i=convert(k/n, confrac)), 0), k=1..n):
seq(a(n), n=1..60); # Alois P. Heinz, Jan 31 2023
MATHEMATICA
a[n_] := Total@ Flatten@ (ContinuedFraction[#/n] & /@ Select[Range[n], CoprimeQ[#, n] &]); Array[a, 100] (* Amiram Eldar, Dec 13 2024 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Jeffrey Shallit, Jan 31 2023
STATUS
approved