login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A020653 Denominators in a certain bijection from positive integers to positive rationals. 23

%I #49 Nov 25 2021 09:03:59

%S 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 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 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 Denominators in a certain bijection from positive integers to positive rationals.

%C 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 Richard Courant and Herbert Robbins. What Is Mathematics?, Oxford, 1941, pp. 79-80.

%D H. Lauwerier, Fractals, Princeton Univ. Press, p. 23.

%H David Wasserman, <a href="/A020653/b020653.txt">Table of n, a(n) for n = 1..100000</a>

%H <a href="/index/Cor#core">Index entries for "core" sequences</a>

%H <a href="/index/Ra#rational">Index entries for sequences related to enumerating the rationals</a>

%e From _M. F. Hasler_, Nov 25 2021: (Start)

%e 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 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 (End)

%p 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 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 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 (Haskell)

%o a020653 n = a020653_list !! (n-1)

%o a020653_list = concat $ map reverse $ tail a038566_tabf

%o -- _Reinhard Zumkeller_, Oct 30 2012

%o (Python)

%o from sympy import totient, gcd

%o def a(n):

%o s=0

%o k=2

%o while s<n:

%o s+=totient(k)

%o k+=1

%o s-=totient(k - 1)

%o j=1

%o while s<n:

%o if gcd(j, k - 1)==1: s+=1

%o j+=1

%o return k - j # _Indranil Ghosh_, May 23 2017, translated from Ulrich Schimke's MAPLE code

%Y Cf. A020652, A038566, A038569.

%K nonn,frac,core,nice

%O 1,2

%A _David W. Wilson_

%E Definition clarified by _N. J. A. Sloane_, Nov 25 2021

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 25 03:15 EDT 2024. Contains 371964 sequences. (Running on oeis4.)