A010751 Up once, down twice, up three times, down four times, ...
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
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)
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)
Comments