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.

A340944 List of X-coordinates of point moving along one of the arms of a counterclockwise square spiral with four arms; A340945 gives Y-coordinates.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Jan 30 2021

Keywords

Examples

			The spiral starts as follows:
     +-----+-----+-----+-----+
     |7     6     5     4    |3    .
     |                       |     .
     +     +-----+-----+     +     +
     |8    |           |     |2    |
     |     |           |     |     |
     +     +     +-----+-----+     +
     |9    |     |     |0     1    |
     |     |     |     |           |     .
     +     +     +     +-----+-----+     .
     |10   |     |                       .
     |     |     |                       .
     +     +     +-----+-----+-----+-----+
     .11   .
     .
- so a(0) = a(4) = 0,
     a(1) = a(2) = a(3) = 1,
     a(5) = -1,
     a(6) = -2,
     a(7) = a(8) = a(9) = a(10) = a(11) = -3.
		

Crossrefs

Programs

  • PARI
    See Links section.
    
  • PARI
    a(n) = my(r,s=sqrtint(n,&r)); if(r>s, s++;r-=2*s-1); real((r-s*I)*I^s); \\ Kevin Ryde, May 24 2023

Formula

a(n) = A340945(n) iff n belongs to A002939.
a(n) = - A340945(n) iff n = 4*x^2 - 6*x + 2 for some x.
a(n) = 0 iff n is an even square (A016742).
a(n) = Re z where z = (r-s*i)*i^s with s = round(sqrt(n)) = A000194(n) and remainder r = n - s^2. - Kevin Ryde, May 24 2023