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.

A329116 Successively count to (-1)^(n+1)*n (n = 0, 1, 2, ... ).

Original entry on oeis.org

0, 1, 0, -1, -2, -1, 0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8
Offset: 0

Views

Author

Mikk Heidemaa, Nov 13 2019

Keywords

Comments

Also x-coordinates of a point moving in counterclockwise triangular spiral (A329972 gives the y-coordinates).

Examples

			   y
     |
   4 |                         56
     |                           \
     |                            \
     |                             \
   3 |                         30  55
     |                         / \   \
     |                        /   \   \
     |                       /     \   \
   2 |                     31  12  29  54
     |                     /   / \   \   \
     |                    /   /   \   \   \
     |                   /   /     \   \   \
   1 |                 32  13   2  11  28  53
     |                 /   /   / \   \   \   \
     |                /   /   /   \   \   \   \
     |               /   /   /     \   \   \   \
   0 |             33  14   3   0---1  10  27  52
     |             /   /   /             \   \   \
     |            /   /   /               \   \   \
     |           /   /   /                 \   \   \
  -1 |         34  15   4---5---6---7---8---9  26  51
     |         /   /                             \   \
     |        /   /                               \   \
     |       /   /                                 \   \
  -2 |     35  16--17--18--19--20--21--22--23--24--25  50
     |     /                                             \
     |    /                                               \
     |   /                                                 \
  -3 | 36--37--38--39--40--41--42--43--44--45--46--47--48--49
     |
     +--------------------------------------------------------
   x:  -6  -5  -4  -3  -2  -1   0   1   2   3   4   5   6   7
We count as follows. Start at n=0 with 0.
Next step is to count to 1: so we have 0, 1.
Next step is to count to -2, so we have 0, 1, 0, -1, -2.
Next we have to go to +3, so we have 0, 1, 0, -1, -2, -1, 0, 1, 2, 3.
And so on.
		

Crossrefs

Cf. A053615, A196199, A339265 (first differences). Essentially the same as A255175.

Programs

  • Mathematica
    a[n_] := Table[(-1)^(# + 1)*(-#^2 + # + k) &[Ceiling@ Sqrt@ k], {k, 0, n}]; a[64]
  • Python
    from math import isqrt
    def A329116(n): return ((t:=1+isqrt(n-1))*(t-1)-n)*(-1 if t&1 else 1) if n else 0 # Chai Wah Wu, Aug 04 2022

Formula

a(n) = (-1)^t * (t^2 - t - n) where t=ceiling(sqrt(n)).
a(n) = (-1)^t * floor(t^2 - sqrt(n) - n) where t=ceiling(sqrt(n)).
A053615(n) = abs(a(n)).
abs(A196199(n)) = abs(a(n)).
A255175(n) = a(n+1).

A331363 Pairs of coordinates of the corners in a counterclockwise triangular spiral.

Original entry on oeis.org

0, 0, 1, 0, 0, 1, -2, -1, 3, -1, 0, 2, -4, -2, 5, -2, 0, 3, -6, -3, 7, -3, 0, 4, -8, -4, 9, -4, 0, 5, -10, -5, 11, -5, 0, 6, -12, -6, 13, -6, 0, 7, -14, -7, 15, -7, 0, 8, -16, -8, 17, -8, 0, 9, -18, -9, 19, -9, 0, 10, -20, -10, 21, -10, 0, 11
Offset: 1

Views

Author

Mikk Heidemaa, May 03 2020

Keywords

Comments

Odd n yields the x- and even n the y-coordinates (i.e., x- and y-coordinates alternate in the sequence).

Examples

			X- and y-coordinates of the corners alternate in the sequence: 0, 0, 1, 0, 0, 1, -2,-1, 3, -1, ...
                      (0,4)
                     .     \
                    .       \
                   .         \
                      (0,3)   \
                     /     \   \
                    /       \   \
                   /         \   \
                  /   (0,2)   \   \
                 /   /     \   \   \
                /   /       \   \   \
               /   /         \   \   \
              /   /   (0,1)   \   \   \
             /   /   /     \   \   \   \
            /   /   /       \   \   \   \
           /   /   /         \   \   \   \
          /   /   /   (0,0)->(1,0)\   \   \
         /   /   /                 \   \   \
        /   /   /                   \   \   \
       /   /  (-2,-1)------------->(3,-1)\   \
      /   /                               \   \
     /   /                                 \   \
    /  (-4,-2)--------------------------->(5,-2)\
   /                                             \
  /                                               \
(-6,-3)------------------------------------------>(7,-3)
		

Crossrefs

Programs

  • Mathematica
    a[n_] := Ceiling[1/18*n*(Mod[2 - n, 6] + 4*Mod[n, -3] + 1)]; Table[ a[n], {n, 66}] (* or *)
    LinearRecurrence[{0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, -1}, {0, 0, 1, 0, 0, 1, -2, -1, 3, -1, 0, 2}, 66]

Formula

a(n) = ceiling(1/18*n*((2 - n) mod 6 + 4*n mod (-3) + 1)), for n >= 1.
x(n) = ceiling(n - 2/3*(n^2 + 1) mod 3), for n >= 1 (x-coordinates).
y(n) = floor(2*n/3)*((2 - n) mod (-3) + 1), for n >= 1 (y-coordinates).
From Colin Barker, May 03 2020: (Start)
G.f.: x^3*(1 + x^3 - 2*x^4 - x^5 + x^6 - x^7) / ((1 - x)^2*(1 + x)^2*(1 - x + x^2)^2*(1 + x + x^2)^2).
a(n) = 2*a(n-6) - a(n-12) for n>12.
(End)
From Wolfdieter Lang, Jul 13 2020: (Start)
Bisection: x(k) = a(2*k-1). x(3+3*l) = 0, x(1+3*l) = -2*l, x(2+3*l) = 1+2*l, for l >= 0.
x(k) = (2*(k-1)*modp((k-4)^2,3) - (2*k-1)*modp((k-2)^2,3) + 1)/3, for k >= 1.
y(k) = a(2*k). y(3+3*k) = 1+l, y(1+3*k) = -l = y(2+3*k), for l >= 0.
y(k) = ((k-1)*modp((k-1)^2,3) + (k-2)*modp((k+1)^2,3) - k*modp(k^2,3) -(k-3))/3, k >= 1.
G.f.s: Gx(t) = t^2*(1 - 2*t^2 + t^3)/(1 - t^3)^2, and Gy(t) = t^3*(1 - t - t^2) / (1 - t^3)^2.
This produces the g.f. G(x) = Gy(x^2) + Gx(x^2)/x given by Colin Barker.
(End)

A343203 Sum of x- and y-coordinate of a point moving in a triangular spiral.

Original entry on oeis.org

0, 1, 1, -1, -3, -2, -1, 0, 1, 2, 2, 2, 2, 0, -2, -4, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 3, 3, 3, 3, 3, 1, -1, -3, -5, -7, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 2, 0, -2, -4, -6, -8, -10, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 1, -1, -3, -5, -7, -9, -11, -13, -15
Offset: 0

Views

Author

Hans G. Oberlack, Apr 07 2021

Keywords

Examples

			   y
     |
   4 |                         56
     |                           \
     |                            \
     |                             \
   3 |                         30  55
     |                         / \   \
     |                        /   \   \
     |                       /     \   \
   2 |                     31  12  29  54
     |                     /   / \   \   \
     |                    /   /   \   \   \
     |                   /   /     \   \   \
   1 |                 32  13   2  11  28  53
     |                 /   /   / \   \   \   \
     |                /   /   /   \   \   \   \
     |               /   /   /     \   \   \   \
   0 |             33  14   3   0---1  10  27  52
     |             /   /   /             \   \   \
     |            /   /   /               \   \   \
     |           /   /   /                 \   \   \
  -1 |         34  15   4---5---6---7---8---9  26  51
     |         /   /                             \   \
     |        /   /                               \   \
     |       /   /                                 \   \
  -2 |     35  16--17--18--19--20--21--22--23--24--25  50
     |     /                                             \
     |    /                                               \
     |   /                                                 \
  -3 | 36--37--38--39--40--41--42--43--44--45--46--47--48--49
     |
     +--------------------------------------------------------
   x:  -6  -5  -4  -3  -2  -1   0   1   2   3   4   5   6   7
Count as follows. Start at n=0 with coordinates (0,0). So first term is 0.
Next step is to move to n=1 with coordinates (1,0) resulting in sum=1. So the sequence begins 0,1,...
Next step is to move to n=2 with coordinates (0,1) resulting in sum=1. So the sequence begins 0,1,1,...
Next step is to move to n=3 with coordinates (-1,0) resulting in sum=-1. So the sequence begins 0,1,1,1,...
Next step is to move to n=4 with coordinates (-2,-1) resulting in sum=-3. So the sequence begins 0,1,1,-1,-3,...
and so on.
		

Crossrefs

Showing 1-3 of 3 results.