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.

Showing 1-3 of 3 results.

A317825 a(1) = 1, a(n) = 3*a(n/2) if n is even, a(n) = n - a(n-1) if n is odd.

Original entry on oeis.org

1, 3, 0, 9, -4, 0, 7, 27, -18, -12, 23, 0, 13, 21, -6, 81, -64, -54, 73, -36, 57, 69, -46, 0, 25, 39, -12, 63, -34, -18, 49, 243, -210, -192, 227, -162, 199, 219, -180, -108, 149, 171, -128, 207, -162, -138, 185, 0, 49, 75, -24, 117, -64, -36, 91, 189, -132, -102, 161, -54, 115, 147, -84, 729, -664, -630, 697, -576
Offset: 1

Views

Author

Altug Alkan and Antti Karttunen, Aug 22 2018

Keywords

Comments

Sequence has an elegant fractal-like scatter plot, situated (approximately) symmetrically over X-axis.
This sequence can also be generalized with some modifications. Let f_k(1) = 1. f_k(n) = floor(k*a(n/2)) if n is even, f_k(n) = n - f_k(n-1) if n is odd. This sequence is a(n) = f_k(n) where k = 3. For example, if k is e (A001113), then recurrence also provides a curious fractal-like structure that has some similarities with a(n). See Links section for their plots.
A scatterplot of (Sum_{i = 1..2*n} a(i)) - n^2 gives a similar plot as for a(n). - A.H.M. Smeets, Sep 01 2018

Crossrefs

Programs

  • Magma
    [n eq 1 select 1 else IsEven(n) select 3*Self(n div 2) else n- Self(n-1): n in [1..80]]; // Vincenzo Librandi, Sep 03 2018
  • Mathematica
    Nest[Append[#1, If[EvenQ[#2], 3 #1[[#2/2]], #2 - #1[[-1]] ]] & @@ {#, Length@ # + 1} &, {1}, 67] (* Michael De Vlieger, Aug 22 2018 *)
  • PARI
    A317825(n) = if(1==n,n,if(!(n%2),3*A317825(n/2),n-A317825(n-1)));
    
  • Python
    aa = [0]
    a,n = 0,0
    while n < 16383:
        n = n+1
        if n%2 == 0:
            a = 3*aa[n//2]
        else:
            a = n-a
        aa = aa+[a]
        print(n,a) # A.H.M. Smeets, Sep 01 2018
    

Formula

From A.H.M. Smeets, Sep 01 2018: (Start)
Sum_{i = 1..2*n-1} a(i) = n^2 for n >= 0.
Sum_{i = 1..2*n} a(i) = 3*a(n) + n^2 for n >= 0, a(0) = 0.
Sum_{i = 1..36*2^n} a(i) = 162*A085350(n) for n >= 0.
Lim_{n -> infinity} a(n)/n^2 = 0.
Lim_{n -> infinity} (Sum_{i = 1..n} a(i))/n^2 = 1/4. (End)

A305865 a(1) = 1, a(n) = -5*a(n/3) if n is divisible by 3, otherwise a(n) = n - a(n-1).

Original entry on oeis.org

1, 1, -5, 9, -4, -5, 12, -4, 25, -15, 26, -45, 58, -44, 20, -4, 21, 25, -6, 26, -60, 82, -59, 20, 5, 21, -125, 153, -124, 75, -44, 76, -130, 164, -129, 225, -188, 226, -290, 330, -289, 220, -177, 221, -100, 146, -99, 20, 29, 21, -105, 157, -104, -125, 180, -124, 30, 28, 31, -130, 191, -129, 300, -236, 301, -410, 477, -409, 295
Offset: 1

Views

Author

Altug Alkan, Aug 23 2018

Keywords

Crossrefs

Cf. A318265.

Programs

  • Maple
    f:= proc(n) option remember;
      if n mod 3 = 0 then -5*procname(n/3)
      else n - procname(n-1)
      fi
    end proc:
    f(1):= 1:
    map(f, [$1..100]); # Robert Israel, Aug 24 2018
  • PARI
    a(n)=if(n==1, n, if(n%3==0, -5*a(n/3),n-a(n-1)));

Formula

G.f. g(x) satisfies g(x) = -5*(1-x+x^2)*g(x^3) + (1+x+2*x^3-x^4)*x/(1-x^3)^2. - Robert Israel, Aug 24 2018

A318303 a(0) = 0, a(n) = n + a(n-1) if n is odd, a(n) = -3*a(n/2) if n is even.

Original entry on oeis.org

0, 1, -3, 0, 9, 14, 0, 7, -27, -18, -42, -31, 0, 13, -21, -6, 81, 98, 54, 73, 126, 147, 93, 116, 0, 25, -39, -12, 63, 92, 18, 49, -243, -210, -294, -259, -162, -125, -219, -180, -378, -337, -441, -398, -279, -234, -348, -301, 0, 49, -75, -24, 117, 170, 36, 91, -189, -132, -276, -217, -54, 7, -147, -84, 729, 794, 630
Offset: 0

Views

Author

Altug Alkan, Aug 24 2018

Keywords

Comments

Let g_k(0) = 0. g_k(n) = n + g_k(n-1) if n is odd, g_k(n) = k*a(n/2) if n is even. A228451(n) is g_1(n), A298011(n) is g_2(n). This sequence is a(n) = g_k(n) where k = -3.

Crossrefs

Programs

  • Mathematica
    Nest[Append[#1, If[OddQ@ #2, #2 + #1[[-1]], -3 #1[[#2/2 + 1]] ]] & @@ {#, Length@ #} &, {0}, 66] (* Michael De Vlieger, Aug 25 2018 *)
  • PARI
    a(n)=if(n==0, 0, if(n%2, n+a(n-1), -3*a(n/2)));
Showing 1-3 of 3 results.