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.

A010751 Up once, down twice, up three times, down four times, ...

Original entry on oeis.org

0, 1, 0, -1, 0, 1, 2, 1, 0, -1, -2, -1, 0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 3, 4, 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, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -5, -4
Offset: 0

Views

Author

David Berends (dave(AT)pgt.com)

Keywords

Comments

Also x-coordinates of a point moving in a spiral rotated by Pi/4, with y-coordinates given by A305258. - Hugo Pfoertner, May 29 2018
This sequence is also obtained by reading alternately in ascending or descending way the antidiagonals of the array defined as A(i, j) = floor((j - i + 1)/2) (see Example). - Stefano Spezia, Jan 02 2022

Examples

			From _Stefano Spezia_, Jan 02 2022: (Start)
The array A begins with:
   0   1   1   2   2   3   3 ...
   0   0   1   1   2   2   3 ...
  -1   0   0   1   1   2   2 ...
  -1  -1   0   0   1   1   2 ...
  -2  -1  -1   0   0   1   1 ...
  -2  -2  -1  -1   0   0   1 ...
  ...
(End)
		

Crossrefs

Programs

  • Mathematica
    n=(the index); x = -1; y = 0; While[n != 0, While[y != x && n != 0, y--; n-- ]; While[y != -x && n != 0, n--; y++ ]; x-- ]; Print[ -y] (* provided by Gregory Puleo *)
    n = (the index); a = Floor[(-1 - Sqrt[1 + 8* n])/4]; b = -Floor[(1 - Sqrt[1 + 8*n])/4]; a + 1 - Sign[a*(2*a + 1) - b*(2*b + 1)]*(n - 2*a^2 - 3*a - 1) (* Mark Spindler, Mar 25 2004 *)
  • PARI
    step=-1;print1(x=0,", ");for(stride=1,12,step=-step;for(k=1,stride,print1(x+=step,", "))) \\ Hugo Pfoertner, Jun 02 2018
    
  • Python
    from math import isqrt
    def A010751(n): return n-(m**2>>1) if (m:=isqrt(n+1<<3)+1>>1)&1 else (m**2>>1)-n # Chai Wah Wu, Jun 08 2025

Formula

a(n) = x + 1 - (sign(x(2x+1) - y(2y+1)))*(n-2x^2-3x-1) where x = floor((-1-sqrt(1+8n))/4), y = -floor((1-sqrt(1+8n))/4), sign(x) = abs(x)/x when x is not 0 and sign(0) = 0, floor(x) is the greatest integer less than or equal to x, sqrt(x) is the principal square root of x and abs(x) is the absolute value (or magnitude) of x. - Mark Spindler, Mar 25 2004
From David A. Corneth, Jun 02 2018: (Start)
a(A007590(k)) = a(floor(k^2 / 2)) = 0.
a(A000384(k)) = a(binomial(2 * k, 2)) = k, a new maximum so far.
a(A014105(k)) = a(binomial(2 * k + 1, 2)) = -k, a new minimum so far.
(End)
a(n) = (-1)^A002024(n+1)*(A007590(A002024(n+1))-n). - William McCarty, Jul 30 2021