OFFSET
1,1
COMMENTS
The binary representation of the triangular number t (least significant bits of a(n)) is allowed to have leading zeros.
The sequence of indices of a(n) begins: 2, 3, 5, 7, 14, 26, 31, 60, 119, 248, 509, 1008, 2014, 4064, 8101, 8191, 16320, 32674, 65408, 130877, 261888, 523870, 1048064, 2096204, 4193280, 8386264, 16775168, 33553744, ...
EXAMPLE
105 = (1101001)_2 = (110)_2//(1)_2//(001)_2 is in the sequence, where 105, (110)_2 = 6 and (001)_2=1 are each triangular numbers.
MAPLE
A000217 := proc(n)
n*(n+1) /2 ;
end proc:
isA000217 := proc(n)
local t1;
t1:=floor(sqrt(2*n));
if n = t1*(t1+1)/2 then
true
else
false;
end if;
end proc:
for n from 2 do
tmain := A000217(n) ;
dgs := convert(tmain, base, 2) ;
ndgs := floor(nops(dgs)/2) ;
tlo := [op(1..ndgs, dgs)] ;
if type(nops(dgs), 'even') then
thi := [op(ndgs+1..2*ndgs, dgs)] ;
else
thi := [op(ndgs+2..2*ndgs+1, dgs)] ;
end if;
tlo := add(op(i, tlo)*2^(i-1), i=1..nops(tlo)) ;
if isA000217(tlo) then
thi := add(op(i, thi)*2^(i-1), i=1..nops(thi)) ;
if isA000217(thi) then
printf("%d, \n", tmain) ;
end if;
end if;
end do: # R. J. Mathar, Jun 18 2013
PROG
(C)
#include <stdio.h>
#include <math.h>
typedef unsigned long long U64;
U64 isTriangular(U64 a) { // ! Must be a < (1<<63)
U64 s = sqrt(a*2);
return (s*(s+1) == a*2);
}
int main() {
U64 i, j, n, tn, t, T, prev=0;
for (n = tn = 3; tn > prev; prev = tn, tn += n, ++n) {
for (i = 64, j = tn; j < (1ULL<<63); j += j)
--i; // binary length of tn
j = i >> 1; // TOt or Tt, binary length of t is j
t = tn & ((1ULL<<j)-1);
T = tn >> (j+(i&1));
if (isTriangular(t) && isTriangular(T))
printf("%20llu %10llu %10llu\n", tn, T, t);
}
return 0;
}
CROSSREFS
KEYWORD
nonn,base,less
AUTHOR
Alex Ratushnyak, Jun 16 2013
STATUS
approved