login
A020653
Denominators in a certain bijection from positive integers to positive rationals.
24
1, 2, 1, 3, 1, 4, 3, 2, 1, 5, 1, 6, 5, 4, 3, 2, 1, 7, 5, 3, 1, 8, 7, 5, 4, 2, 1, 9, 7, 3, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 7, 5, 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 13, 11, 9, 5, 3, 1, 14, 13, 11, 8, 7, 4, 2, 1, 15, 13, 11, 9, 7, 5, 3, 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 17
OFFSET
1,2
COMMENTS
This bijection lists the fractions p/q (in lowest terms) by increasing p+q, then by increasing p (see the example). The variant A038569 corresponds to the bijection where each fraction p/q with p < q is followed by its reciprocal q/p. - M. F. Hasler, Oct 25 2021
REFERENCES
Richard Courant and Herbert Robbins. What Is Mathematics?, Oxford, 1941, pp. 79-80.
H. Lauwerier, Fractals, Princeton Univ. Press, p. 23.
EXAMPLE
From M. F. Hasler, Nov 25 2021: (Start)
This sequence gives the denominators of the positive fractions p/q (in lowest terms) when they are listed by increasing p+q, then by increasing p:
1/1; 1/2, 2/1; 1/3, 3/1; 1/4, 2/3, 3/2, 4/1; 1/5, 5/1; 1/6, 2/5, 3/4, 4/3, 5/2, 6/1; ...
(End)
MAPLE
with (numtheory): A020653 := proc (n) local sum, j, k; sum := 0: k := 2: while (sum < n) do: sum := sum + phi(k): k := k + 1: od: sum := sum - phi(k-1): j := 1; while sum < n do: if gcd(j, k-1) = 1 then sum := sum + 1: fi: j := j+1: od: RETURN (k-j): end: # Ulrich Schimke (ulrschimke(AT)aol.com), Nov 06 2001
MATHEMATICA
a[n_] := Module[{s=0, k=2}, While [s < n, s = s + EulerPhi[k]; k = k+1]; s = s - EulerPhi[k-1]; j=1; While[s < n , If[GCD[j, k-1] == 1 , s = s+1]; j = j+1]; k-j]; Table[a[n], {n, 1, 96}] (* Jean-François Alcover, Dec 06 2012, after Ulrich Schimke's Maple program *)
Flatten[Map[Denominator[#/Reverse[#]]&, Table[Flatten[Position[GCD[Map[Mod[#, n]&, Range[n-1]], n], 1]], {n, 100}]]] (* Peter J. C. Moses, Apr 17 2013 *)
PROG
(Haskell)
a020653 n = a020653_list !! (n-1)
a020653_list = concat $ map reverse $ tail a038566_tabf
-- Reinhard Zumkeller, Oct 30 2012
(Python)
from sympy import totient, gcd
def a(n):
s=0
k=2
while s<n:
s+=totient(k)
k+=1
s-=totient(k - 1)
j=1
while s<n:
if gcd(j, k - 1)==1: s+=1
j+=1
return k - j # Indranil Ghosh, May 23 2017, translated from Ulrich Schimke's MAPLE code
(PARI) a(n) = my(s=0, k=1, j=1); while(s<n, s+=eulerphi(k++)); s-=eulerphi(k); while(s<n, if(1==gcd(j, k), s++); j++); k+1-j; \\ Ruud H.G. van Tol, May 14 2024
CROSSREFS
KEYWORD
nonn,frac,core,nice
EXTENSIONS
Definition clarified by N. J. A. Sloane, Nov 25 2021
STATUS
approved