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.

A273672 Permutation of natural numbers induced by looking up the position of fraction A270418(n)/A270419(n) from the full Stern-Brocot tree A007305(n+1)/A047679(n-1).

Original entry on oeis.org

1, 3, 7, 15, 31, 63, 127, 2, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 6, 33554431, 67108863, 4, 268435455, 536870911, 1073741823, 2147483647, 128, 8589934591, 17179869183, 34359738367, 68719476735, 137438953471, 274877906943, 549755813887, 14
Offset: 1

Views

Author

Antti Karttunen, May 27 2016

Keywords

Crossrefs

Inverse: A273671.
Cf. also A007305, A047679.

Programs

  • PARI
    A065620(n, c=1) = sum(i=0, logint(n+!n, 2), if(bittest(n, i), (-1)^c++<A065620
    SBtree_index(r) = { my(m=numerator(r),n=denominator(r),z=1); while(m!=n, if(mA273672(n) = { n=factor(n); n[, 2] = apply(A065620, n[, 2]); SBtree_index(factorback(n)); }; \\ Antti Karttunen, Mar 07 2020, based also on M. F. Hasler's code in A270418 and A270419
  • Scheme
    (define (A273672 n) (SBtree_index (A270418 n) (A270419 n)))
    (define (SBtree_index m n) (let loop ((m m) (n n) (z 1)) (cond ((= m n) z) ((< m n) (loop m (- n m) (+ z z))) (else (loop (- m n) n (+ z z 1))))))