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.

A206297 Position of n in the canonical bijection from the positive integers to the positive rational numbers.

This page as a plain text file.
%I A206297 #28 Aug 04 2024 20:07:12
%S A206297 1,3,5,9,13,21,25,37,45,57,65,85,93,117,129,145,161,193,205,241,257,
%T A206297 281,301,345,361,401,425,461,485,541,557,617,649,689,721,769,793,865,
%U A206297 901,949,981,1061,1085,1169,1209,1257,1301,1393,1425,1509,1549
%N A206297 Position of n in the canonical bijection from the positive integers to the positive rational numbers.
%C A206297 The canonical bijection from the positive integers to the positive rational numbers is given by A038568(n)/A038569(n).
%C A206297 Appears to be a variant of A049691. - _R. J. Mathar_, Feb 11 2012
%C A206297 It appears that a(n) = 2*A005728(n) - 1. - _Chris Boyd_, Mar 21 2015
%H A206297 G. C. Greubel, <a href="/A206297/b206297.txt">Table of n, a(n) for n = 1..1000</a>
%e A206297 The canonical bijection starts with 1/1, 1/2, 2/1, 1/3, 3/1, 2/3, 3/2, 1/4, 4/1, 3/4, 4/3, 1/5, 5/1, so that this sequence starts with 1,3,5,9,13 and A206350 starts with 1,2,4,8,12.
%t A206297 a[n_] := Module[{s = 1, k = 2, j = 1},
%t A206297   While[s <= n, s = s + 2*EulerPhi[k]; k = k + 1];
%t A206297   s = s - 2*EulerPhi[k - 1];
%t A206297   While[s <= n, If[GCD[j, k - 1] =
%t A206297     = 1, s = s + 2]; j = j + 1];
%t A206297   If[s > n + 1, j - 1, k - 1]];
%t A206297 t = Table[a[n], {n, 0, 3000}];   (* A038568 *)
%t A206297 ReplacePart[1 + Flatten[Position[t, 1]], 1, 1]
%t A206297 (* A206297 *)
%o A206297 (Python)
%o A206297 from functools import lru_cache
%o A206297 @lru_cache(maxsize=None)
%o A206297 def A206297(n):
%o A206297     if n == 1:
%o A206297         return 1
%o A206297     c, j = 1, 2
%o A206297     k1 = (n-1)//j
%o A206297     while k1 > 1:
%o A206297         j2 = (n-1)//k1 + 1
%o A206297         c += (j2-j)*(A206297(k1+1)-2)
%o A206297         j, k1 = j2, (n-1)//j2
%o A206297     return (n-2)*(n-1)-c+j+2 # _Chai Wah Wu_, Aug 04 2024
%Y A206297 Cf. A038568, A038569, A206350.
%Y A206297 A049691 is an essentially identical sequence. See also A018805.
%K A206297 nonn
%O A206297 1,2
%A A206297 _Clark Kimberling_, Feb 06 2012