cp's OEIS Frontend

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.

A020652 Numerators in canonical bijection from positive integers to positive rationals.

This page as a plain text file.
%I A020652 #60 May 12 2024 13:08:29
%S A020652 1,1,2,1,3,1,2,3,4,1,5,1,2,3,4,5,6,1,3,5,7,1,2,4,5,7,8,1,3,7,9,1,2,3,
%T A020652 4,5,6,7,8,9,10,1,5,7,11,1,2,3,4,5,6,7,8,9,10,11,12,1,3,5,9,11,13,1,2,
%U A020652 4,7,8,11,13,14,1,3,5,7,9,11,13,15,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,1,5
%N A020652 Numerators in canonical bijection from positive integers to positive rationals.
%C A020652 a(A002088(n)) = 1 for n > 1. - _Reinhard Zumkeller_, Jul 29 2012
%C A020652 When read as an irregular table with each 1 entry starting a new row, then the n-th row consists of the set of multiplicative units of Z_{n+1}. These rows form a group under multiplication mod n. - _Tom Edgar_, Aug 20 2013
%C A020652 The pair of sequences A020652/A020653 is defined by ordering the positive fractions p/q (reduced to lowest terms) by increasing p+q, then increasing p: 1/1; 1/2, 2/1; 1/3, 3/1; 1/4, 2/3, 3/2, 4/1; 1/5, 5/1; 2/5, 3/4, 4/3, 5/2; etc. For given p+q, there are A000010(p+q) fractions, listed starting at index A002088(p+q-1). - _M. F. Hasler_, Mar 06 2020
%D A020652 S. Cook, Problem 511: An Enumeration Problem, Journal of Recreational Mathematics, Vol. 9:2 (1976-77), 137. Solution by the Problem Editor, JRM, Vol. 10:2 (1977-78), 122-123.
%D A020652 Richard Courant and Herbert Robbins. What Is Mathematics?, Oxford, 1941, pp. 79-80.
%D A020652 H. Lauwerier, Fractals, Princeton Univ. Press, p. 23.
%H A020652 David Wasserman, <a href="/A020652/b020652.txt">Table of n, a(n) for n = 1..100000</a>
%H A020652 Paul Yiu, <a href="http://math.fau.edu/Yiu/RecreationalMathematics2003.pdf">Recreational Mathematics</a>, 24.3.1 Appendix: Two enumerations of the rational numbers in (0,1), page 633.
%H A020652 <a href="/index/Cor#core">Index entries for "core" sequences</a>
%H A020652 <a href="/index/Ra#rational">Index entries for sequences related to enumerating the rationals</a>
%H A020652 <a href="/index/St#Stern">Index entries for sequences related to Stern's sequences</a>
%e A020652 Arrange positive fractions < 1 by increasing denominator then by increasing numerator: 1/2, 1/3, 2/3, 1/4, 3/4, 1/5, 2/5, 3/5, 4/5, 1/6 ... (this is A020652/A038567). - _William Rex Marshall_, Dec 16 2010
%p A020652 with (numtheory): A020652 := 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 (j-1): end: # Ulrich Schimke (ulrschimke(AT)aol.com), Nov 06 2001
%t A020652 Reap[Do[If[GCD[num, den] == 1, Sow[num]], {den, 1, 20}, {num, 1, den-1}] ][[2, 1]] (* _Jean-François Alcover_, Oct 22 2012 *)
%o A020652 (Haskell)
%o A020652 a020652 n = a020652_list !! (n-1)
%o A020652 a020652_list = map fst [(u,v) | v <- [1..], u <- [1..v-1], gcd u v == 1]
%o A020652 -- _Reinhard Zumkeller_, Jul 29 2012
%o A020652 (PARI) a(n)=my(s,j=1,k=1);while(s<n,s+=eulerphi(k++););s-=eulerphi(k);while(s<n,if(gcd(j,k)==1,s++);j++);j-1 \\ _Charles R Greathouse IV_, Feb 07 2013
%o A020652 (Python)
%o A020652 from sympy import totient, gcd
%o A020652 def a(n):
%o A020652     s=0
%o A020652     k=2
%o A020652     while s<n:
%o A020652         s+=totient(k)
%o A020652         k+=1
%o A020652     s-=totient(k - 1)
%o A020652     j=1
%o A020652     while s<n:
%o A020652         if gcd(j, k - 1)==1:
%o A020652             s+=1
%o A020652         j+=1
%o A020652     return j - 1
%o A020652 print([a(n) for n in range(1, 101)]) # _Indranil Ghosh_, May 23 2017, after Ulrich Schimke's MAPLE code
%Y A020652 Essentially the same as A038566, which is the main entry for this sequence.
%Y A020652 Cf. A020653, A038567-A038569, A182972-A182976.
%Y A020652 A054424 gives mapping to Stern-Brocot tree.
%Y A020652 Cf. A037161.
%K A020652 nonn,frac,core,nice,tabf
%O A020652 1,3
%A A020652 _David W. Wilson_