This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A020653 #53 May 14 2024 09:13:52 %S A020653 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, %T A020653 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, %U A020653 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 %N A020653 Denominators in a certain bijection from positive integers to positive rationals. %C A020653 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 %D A020653 Richard Courant and Herbert Robbins. What Is Mathematics?, Oxford, 1941, pp. 79-80. %D A020653 H. Lauwerier, Fractals, Princeton Univ. Press, p. 23. %H A020653 David Wasserman, <a href="/A020653/b020653.txt">Table of n, a(n) for n = 1..100000</a> %H A020653 <a href="/index/Cor#core">Index entries for "core" sequences</a> %H A020653 <a href="/index/Ra#rational">Index entries for sequences related to enumerating the rationals</a> %e A020653 From _M. F. Hasler_, Nov 25 2021: (Start) %e A020653 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: %e A020653 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; ... %e A020653 (End) %p A020653 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 %t A020653 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 *) %t A020653 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 *) %o A020653 (Haskell) %o A020653 a020653 n = a020653_list !! (n-1) %o A020653 a020653_list = concat $ map reverse $ tail a038566_tabf %o A020653 -- _Reinhard Zumkeller_, Oct 30 2012 %o A020653 (Python) %o A020653 from sympy import totient, gcd %o A020653 def a(n): %o A020653 s=0 %o A020653 k=2 %o A020653 while s<n: %o A020653 s+=totient(k) %o A020653 k+=1 %o A020653 s-=totient(k - 1) %o A020653 j=1 %o A020653 while s<n: %o A020653 if gcd(j, k - 1)==1: s+=1 %o A020653 j+=1 %o A020653 return k - j # _Indranil Ghosh_, May 23 2017, translated from Ulrich Schimke's MAPLE code %o A020653 (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 %Y A020653 Cf. A020652, A038566, A038569. %K A020653 nonn,frac,core,nice %O A020653 1,2 %A A020653 _David W. Wilson_ %E A020653 Definition clarified by _N. J. A. Sloane_, Nov 25 2021