OFFSET
1,1
COMMENTS
a(n) <= n + 1.
From the Mathematics Stack Exchange question:
Assume there are n stairs (so n+1 places to stand).
Starting from the bottom, go up 1 stair at a time, until you reach the top;
then turn around and go down 2 stairs at a time, until you can't go further;
then turn around and go up 3 stairs at a time, until you can't go further;
then 4, 5, 6, etc. stairs at a time, until you can't even make one step.
LINKS
Peter Kagey, Table of n, a(n) for n = 1..10000
Sheljohn, A curious sequence, Mathematics Stack Exchange, Feb 15 2017.
EXAMPLE
For n = 4:
step size 1: 0 -> 1 -> 2 -> 3 -> 4;
step size 2: 4 -> 2 -> 0;
step size 3: 0 -> 3.
Because the walker cannot take four steps down, a(4) = 4.
MAPLE
A282442 := proc(n)
local h, dir, ss, ns;
h := 0 ;
dir := 1 ;
for ss from 1 do
if dir > 0 then
ns := floor((n-h)/ss) ;
else
ns := floor(h/ss) ;
end if;
if ns = 0 then
return ss;
end if;
h := h+dir*ns*ss ;
dir := -dir ;
end do:
end proc:
seq(A282442(n), n=1..100) ; # R. J. Mathar, Feb 25 2017
MATHEMATICA
a[n_] := Module[{h = 0, dir = 1, ss, ns}, For[ss = 1, True, ss++, If[dir > 0, ns = Floor[(n - h)/ss], ns = Floor[h/ss]]; If[ns == 0, Return[ss]]; h = h + dir ns ss; dir = -dir]];
Array[a, 100] (* Jean-François Alcover, Mar 29 2020, after R. J. Mathar *)
CROSSREFS
KEYWORD
nonn,look
AUTHOR
Peter Kagey, Feb 15 2017
STATUS
approved