OFFSET

0,6

COMMENTS

a(k^2-2) = a(k^2-1) = k-1 for any k > 1.

If (a(k), a(k+1)) = (x,y), then max(x,y)^2 <= k < (max(x,y)+1)^2.

LINKS

Paul Tek, Table of n, a(n) for n = 0..10000

FORMULA

a(n) = ([sqrt n]^2 + [(n-[sqrt n]^2)/2])/2 - (-1)^(n-[sqrt n]^2)*([sqrt n]^2-[(n-[sqrt n]^2)/2])/2, where [] represents the floor function. - David Adam, Nov 09 2017

EXAMPLE

a(0)=0.

a(1)=0.

a(2)>0; (0,1) has not yet been visited, hence a(2)=1.

a(3)>0; (1,1) has not yet been visited, hence a(3)=1.

a(4)=0.

a(5)>0; (0,1) has been visited, but (0,2) has not, hence a(5)=2.

a(6)>0; (2,1) has not yet been visited, hence a(6)=1.

a(7)>0; (1,1) has been visited, but (1,2) has not, hence a(7)=2.

a(8)>0; (2,1) has been visited, but (2,2) has not, hence a(8)=2.

a(9)=0.

etc.

PROG

(Perl) my @a = (0);

foreach my $k (1..10) {

push @a => 0, ( map { ($k, $_) } 1..$k-1 ), $k, $k;

}

CROSSREFS

KEYWORD

nonn

AUTHOR

Paul Tek, May 22 2013

STATUS

approved