OFFSET
1,2
COMMENTS
Indices of triangular numbers in A220689. That is, S = triangular(i) XOR triangular(i+1); increment i; if S is a triangular number then index of S is appended to a(n). Initially i=0. XOR is the binary logical exclusive-or operator.
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, t}, i = A224218[[n]]; t = BitXor[PolygonalNumber[i], PolygonalNumber[i + 1]]; (Sqrt[8 t + 1] - 1)/2];
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(t), end=', ')
CROSSREFS
KEYWORD
nonn
AUTHOR
Alex Ratushnyak, Apr 13 2013
STATUS
approved