%I #24 May 22 2016 07:16:39
%S 1,2,6,19,38,102,307,614,1638,4915,9830,26214,78643,157286,419430,
%T 1258291,2516582,6710886,20132659,40265318,107374182,322122547,
%U 644245094,1717986918,5153960755,10307921510,27487790694,82463372083,164926744166,439804651110
%N Numbers n such that ror(n) + rol(n) is a power of 2, where ror(n)=A038572(n) is n rotated one binary place to the right, rol(n)=A006257(n) is n rotated one binary place to the left.
%H Colin Barker, <a href="/A273180/b273180.txt">Table of n, a(n) for n = 1..1000</a>
%H <a href="/index/Rec#order_06">Index entries for linear recurrences with constant coefficients</a>, signature (0,0,17,0,0,-16).
%F From _Colin Barker_, May 19 2016: (Start)
%F a(n) = 17*a(n-3) - 16*a(n-6) for n>6.
%F G.f.: x*(1+2*x+6*x^2+2*x^3+4*x^4) / ((1-x)*(1+x+x^2)*(1-16*x^3)).
%F (End)
%t Select[Range[10^6], IntegerQ@ Log2[FromDigits[RotateRight@ #, 2] + FromDigits[RotateLeft@ #, 2]] &@ IntegerDigits[#, 2] &] (* or *)
%t Rest@ CoefficientList[Series[x (1 + 2 x + 6 x^2 + 2 x^3 + 4 x^4)/((1 - x) (1 + x + x^2) (1 - 16 x^3)), {x, 0, 30}], x] (* _Michael De Vlieger_, May 19 2016 *)
%o (C)
%o #include <stdio.h>
%o int main(int argc, char** argv)
%o {
%o unsigned long long x, n, BL=0;
%o for (n=1; n>0; ++n) {
%o if ((n & (n-1))==0) ++BL;
%o x = (n>>1) + ((n&1) << (BL-1)); // A038572(n)
%o x+= (n*2) - (1ull<<BL) + 1; // A006257(n) for n>0
%o if ((x & (x-1))==0) printf("%lld, ", n);
%o }
%o }
%o (PARI) Vec(x*(1+2*x+6*x^2+2*x^3+4*x^4)/((1-x)*(1+x+x^2)*(1-16*x^3)) + O(x^50)) \\ _Colin Barker_, May 19 2016
%Y Cf. A006257, A038572, A088161, A088163, A112627, A273105, A273106.
%K nonn,base,easy
%O 1,2
%A _Alex Ratushnyak_, May 17 2016
|