OFFSET
1,3
COMMENTS
Numbers k such that bitwise XOR of first k triangular numbers is a triangular number.
PROG
(C)
#include <stdio.h>
typedef unsigned long long U64;
U64 rootTriangular(U64 a) {
U64 sr = 1L<<32, s, b;
if (a < (sr/2)*(sr+1)) {
sr>>=1;
while (a < sr*(sr+1)/2) sr>>=1;
}
for (b = sr>>1; b; b>>=1) {
s = sr+b;
if (a >= s*(s+1)/2) sr = s;
}
return sr;
}
int main() {
U64 a=0, i, t;
for (i=0; i < 1L<<32; ++i) {
a ^= i*(i+1)/2;
t = rootTriangular(a);
if (a == t*(t+1)/2) printf("%llu\n", i);
}
return 0;
}
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Alex Ratushnyak, Mar 27 2013
STATUS
approved