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.

A351412 a(1) = 1, a(2) = 2, a(3) = 3. Then if n is even a(n) is the least positive integer not yet in the sequence, otherwise if n is odd a(n) = a(n-1) + a(n-3).

Original entry on oeis.org

1, 2, 3, 4, 6, 5, 9, 7, 12, 8, 15, 10, 18, 11, 21, 13, 24, 14, 27, 16, 30, 17, 33, 19, 36, 20, 39, 22, 42, 23, 45, 25, 48, 26, 51, 28, 54, 29, 57, 31, 60, 32, 63, 34, 66, 35, 69, 37, 72, 38, 75, 40, 78, 41, 81, 43, 84, 44, 87, 46, 90, 47, 93, 49, 96, 50, 99, 52, 102, 53, 105, 55, 108, 56, 111, 58, 114, 59, 117
Offset: 1

Views

Author

Rodolfo Kurchan, Feb 10 2022

Keywords

Comments

Terms computed by Claudio Meller.

Examples

			For n = 6; n is even so a(6) = 5 because 5 is the least positive integer not yet in the sequence.
For n = 7; n is odd so a(7) = a(6) + a(4) = 5 + 4 = 9.
		

Crossrefs

Programs

  • Mathematica
    a[1] = 1; a[2] = 2; a[3] = 3; a[n_] := a[n] = If[OddQ[n], a[n - 1] + a[n - 3], Module[{k = 4, s = Array[a, n - 1]}, While[! FreeQ[s, k], k++]; k]]; Array[a, 100] (* Amiram Eldar, Feb 10 2022 *)
  • PARI
    s=2^0; for (n=1, #a=vector(79), print1 (a[n]=if (n<=3, n, n%2==0, valuation(s+1, 2), a[n-1]+a[n-3])", "); s=bitor(s, 2^a[n])) \\ Rémy Sigrist, Feb 14 2022
    
  • PARI
    a(n) = if(n==1,1, n%2, 3*n>>1 - 1, 3*n>>2 + 1); \\ Kevin Ryde, Feb 21 2022
    
  • Python
    def A351412(n):
        if n == 1:
            return 1
        q, r = divmod(n, 4)
        if r == 0:
            return n-q+1
        elif r == 2:
            return n-q
        elif r == 1:
            return n+2*q-1
        else:
            return n+2*q # Chai Wah Wu, Feb 19 2022

Formula

a(2*n+1)=3*n; a(4*n+0)=3*n+1; a(4*n+2)=3*n+2. - Kevin Ryde, Feb 11 2022