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 A038568 #39 Feb 25 2021 13:21:33 %S A038568 1,1,2,1,3,2,3,1,4,3,4,1,5,2,5,3,5,4,5,1,6,5,6,1,7,2,7,3,7,4,7,5,7,6, %T A038568 7,1,8,3,8,5,8,7,8,1,9,2,9,4,9,5,9,7,9,8,9,1,10,3,10,7,10,9,10,1,11,2, %U A038568 11,3,11,4,11,5,11,6,11,7,11,8,11,9,11,10,11,1,12,5,12,7,12,11,12,1,13,2 %N A038568 Numerators in canonical bijection from positive integers to positive rationals. %C A038568 Even-indexed terms are positive integers in order, with m occurring phi(m) times. Preceding odd-indexed terms (except for missing initial 0) are the corresponding numbers <= m and relatively prime to m, in increasing order. The denominators are just this sequence shifted left. Thus each positive rational occurs exactly once as a ratio a(n)/a(n+1). - _Franklin T. Adams-Watters_, Dec 06 2006 %D A038568 H. Lauwerier, Fractals, Princeton Univ. Press, p. 23. %H A038568 David Wasserman, <a href="/A038568/b038568.txt">Table of n, a(n) for n = 0..100000</a> %H A038568 <a href="/index/Cor#core">Index entries for "core" sequences</a> %H A038568 <a href="/index/Ra#rational">Index entries for sequences related to enumerating the rationals</a> %e A038568 First arrange fractions by increasing denominator, then by increasing numerator: %e A038568 1/1, 1/2, 1/3, 2/3, 1/4, 3/4, 1/5, 2/5, 3/5, ... (this is A038566/A038567); %e A038568 now follow each term (except the first) with its reciprocal: %e A038568 1/1, 1/2, 2/1, 1/3, 3/1, 2/3, 3/2, 1/4, 4/1, 3/4, 4/3, ... (this is A038568/A038569). %p A038568 with (numtheory): A038568 := proc (n) local sum, j, k; sum := 1: k := 2: while (sum < n) do: sum := sum + 2 * phi(k): k := k + 1: od: sum := sum - 2 * phi(k-1): j := 1: while sum < n do: if gcd(j,k-1) = 1 then sum := sum + 2: fi: j := j+1: od: if sum > n then RETURN (j-1) fi: RETURN (k-1): end: # Ulrich Schimke (ulrschimke(AT)aol.com) %t A038568 a[n_] := Module[{sum = 1, k = 2}, While[sum < n, sum = sum + 2*EulerPhi[k]; k = k+1]; sum = sum - 2*EulerPhi[k-1]; j = 1; While[sum < n, If[GCD[j, k-1] == 1, sum = sum+2]; j = j+1; ]; If[sum > n, Return[j-1]]; Return[k-1] ]; Table[a[n], {n, 1, 100}] (* _Jean-François Alcover_, Nov 21 2012, translated from Maple *) %o A038568 (Python) %o A038568 from sympy import totient, gcd %o A038568 def a(n): %o A038568 s=1 %o A038568 k=2 %o A038568 while s<n: %o A038568 s+=2*totient(k) %o A038568 k+=1 %o A038568 s-=2*totient(k - 1) %o A038568 j=1 %o A038568 while s<n: %o A038568 if gcd(j, k - 1)==1: s+=2 %o A038568 j+=1 %o A038568 if s>n: return j - 1 %o A038568 return k - 1 # _Indranil Ghosh_, May 23 2017, translated from Mathematica %o A038568 (Julia) %o A038568 using Nemo %o A038568 function A038568List(len) %o A038568 a, A = QQ(0), [] %o A038568 for n in 1:len %o A038568 a = next_minimal(a) %o A038568 push!(A, numerator(a)) %o A038568 end %o A038568 A end %o A038568 A038568List(84) |> println # _Peter Luschny_, Mar 13 2018 %o A038568 (PARI) a(n) = { my (e); for (q=1, oo, if (n+1<2*e=eulerphi(q), for (p=1, oo, if (gcd(p,q)==1, if (n+1<2, return ([p,q][n+2]), n-=2))), n-=2*e)) } \\ _Rémy Sigrist_, Feb 25 2021 %Y A038568 Cf. A020652, A020653, A038566, A038567, A038569. %K A038568 nonn,frac,core,easy,nice %O A038568 0,3 %A A038568 _N. J. A. Sloane_ %E A038568 More terms from _Erich Friedman_