OFFSET
1,2
COMMENTS
LINKS
Harvey P. Dale, Table of n, a(n) for n = 1..1000
EXAMPLE
Triangular(18) XOR triangular(19) = 171 XOR 190 = 21, because 21 is a triangular number, 18 is in the sequence.
MAPLE
read("transforms") ;
isA000217 := proc(n)
local t1;
t1:=floor(sqrt(2*n));
if n = t1*(t1+1)/2 then
return true
else
return false;
end if;
end proc:
isA224218 := proc(n)
isA000217(%) ;
end proc:
A224218 := proc(n)
option remember;
if n = 1 then
0;
else
for a from procname(n-1)+1 do
if isA224218(a) then
return a;
end if;
end do:
end if;
end proc: # R. J. Mathar, Apr 23 2013
MATHEMATICA
Join[{0}, Flatten[Position[Partition[Accumulate[Range[5000]], 2, 1], _?(OddQ[ Sqrt[1+8BitXor[#[[1]], #[[2]]]]]&), {1}, Heads->False]]] (* Harvey P. Dale, Dec 05 2014 *)
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(i), end=', ')
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Alex Ratushnyak, Apr 01 2013
STATUS
approved