login
A226005
Lexicographically earliest sequence such that (a(n), a(n+1)) runs through all the pairs of nonnegative integers exactly once, with the constraint that a(n)=0 iff n is a square.
2
0, 0, 1, 1, 0, 2, 1, 2, 2, 0, 3, 1, 3, 2, 3, 3, 0, 4, 1, 4, 2, 4, 3, 4, 4, 0, 5, 1, 5, 2, 5, 3, 5, 4, 5, 5, 0, 6, 1, 6, 2, 6, 3, 6, 4, 6, 5, 6, 6, 0, 7, 1, 7, 2, 7, 3, 7, 4, 7, 5, 7, 6, 7, 7, 0, 8, 1, 8, 2, 8, 3, 8, 4, 8, 5, 8, 6, 8, 7, 8, 8, 0, 9, 1, 9, 2, 9, 3, 9, 4, 9, 5, 9, 6, 9, 7, 9, 8, 9, 9, 0
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.
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
Sequence in context: A337108 A108805 A283305 * A134343 A008441 A253183
KEYWORD
nonn
AUTHOR
Paul Tek, May 22 2013
STATUS
approved