OFFSET
1,2
MAPLE
MATHEMATICA
nmax = 100;
pmax = 2 nmax^2; (* increase coeff 2 if A224218 is too short *)
A224218 = Join[{0}, Flatten[Position[Partition[Accumulate[Range[pmax]], 2, 1], _?(OddQ[Sqrt[1 + 8 BitXor[#[[1]], #[[2]]]]]&), {1}, Heads -> False]]];
a[n_] := Module[{i}, i = A224218[[n]]; BitXor[PolygonalNumber[i], PolygonalNumber[i+1]]];
PROG
(Python)
def rootTriangular(a):
sr = 1<<33
while a < sr*(sr+1)//2:
sr>>=1
b = sr>>1
while b:
s = sr+b
if a >= s*(s+1)//2:
sr = s
b>>=1
return sr
for i in range(1<<12):
s = (i*(i+1)//2) ^ ((i+1)*(i+2)//2)
t = rootTriangular(s)
if s == t*(t+1)//2:
print(str(s), end=', ')
CROSSREFS
KEYWORD
nonn
AUTHOR
Alex Ratushnyak, Apr 13 2013
STATUS
approved