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.

A140265 Permutation of natural numbers: a(n) = A140263(n-1)+1.

Original entry on oeis.org

1, 2, 3, 6, 8, 4, 7, 5, 9, 18, 23, 16, 22, 17, 24, 12, 20, 10, 19, 11, 21, 15, 26, 13, 25, 14, 27, 54, 68, 52, 67, 53, 69, 48, 65, 46, 64, 47, 66, 51, 71, 49, 70, 50, 72, 36, 59, 34, 58, 35, 60, 30, 56, 28, 55, 29, 57, 33, 62, 31, 61, 32, 63, 45, 77, 43, 76, 44, 78, 39, 74, 37
Offset: 1

Views

Author

Antti Karttunen, May 19 2008

Keywords

Crossrefs

Inverse: A140266.

Programs

  • Python
    from sympy import ceiling
    from sympy.ntheory.factor_ import digits
    def a004488(n): return int("".join([str((3 - i)%3) for i in digits(n, 3)[1:]]), 3)
    def a117968(n):
        if n==1: return 2
        if n%3==0: return 3*a117968(n/3)
        elif n%3==1: return 3*a117968((n - 1)/3) + 2
        else: return 3*a117968((n + 1)/3) + 1
    def a117967(n): return 0 if n==0 else a117968(-n) if n<0 else a004488(a117968(n))
    def a001057(n): return -(-1)**n*ceiling(n/2)
    def a(n): return a117967(a001057(n - 1)) + 1 # Indranil Ghosh, Jun 07 2017
  • Scheme
    (define (A140265 n) (+ 1 (A140263 (- n 1))))