login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A295827 a(n) = least odd k > 1 such that n and n*k have the same Hamming weight, or -1 if no such k exists. 2

%I #20 Dec 02 2017 21:57:30

%S -1,-1,3,-1,13,3,3,-1,57,13,35,3,21,3,3,-1,241,57,7,13,13,35,39,3,169,

%T 21,5,3,21,3,3,-1,993,241,11,57,7,7,5,13,3197,13,9,35,3,39,13,3,21,

%U 169,3,21,39,5,47,3,27,21,5,3,13,3,3,-1,4033,993,491,241

%N a(n) = least odd k > 1 such that n and n*k have the same Hamming weight, or -1 if no such k exists.

%C The Hamming weight of a number n is given by A000120(n).

%C Apparently, a(n) = -1 iff n = 2^k for some k >= 0.

%C Apparently, a(2^n + 1) = A020515(n) for any n > 1.

%C a(2^n - 1) = 3 for any n > 1.

%C a(n) = 3 iff n = A077459(k) for some k > 1.

%C This sequence has similarities with A292849: here we want A000120(n*a(n)) = A000120(n), there we want A000120(n*a(n)) = A000120(a(n)).

%C For any n > 0, if a(n) > 0 then A292849(a(n)) <= n.

%H Rémy Sigrist, <a href="/A295827/b295827.txt">Table of n, a(n) for n = 1..8192</a>

%H Rémy Sigrist, <a href="/A295827/a295827.png">Logarithmic scatterplot of the sequence for n=1..2^17 and a(n) < 10^18</a>

%F a(2*n) = a(n) for any n > 0.

%e The first terms, alongside the binary representations of n and of n*a(n), are:

%e n a(n) bin(n) bin(n*a(n))

%e -- ---- ------ -----------

%e 1 -1 1 -1

%e 2 -1 10 -10

%e 3 3 11 1001

%e 4 -1 100 -100

%e 5 13 101 1000001

%e 6 3 110 10010

%e 7 3 111 10101

%e 8 -1 1000 -1000

%e 9 57 1001 1000000001

%e 10 13 1010 10000010

%e 11 35 1011 110000001

%e 12 3 1100 100100

%e 13 21 1101 100010001

%e 14 3 1110 101010

%e 15 3 1111 101101

%e 16 -1 10000 -10000

%e 17 241 10001 1000000000001

%e 18 57 10010 10000000010

%e 19 7 10011 10000101

%e 20 13 10100 100000100

%p f:= proc(n) local k,w;

%p if n = 2^padic:-ordp(n,2) then return -1 fi;

%p w:= convert(convert(n,base,2),`+`);

%p for k from 3 by 2 do

%p if convert(convert(n*k,base,2),`+`)=w then return k fi

%p od

%p end proc:

%p map(f, [$1..100]); # _Robert Israel_, Nov 28 2017

%t Table[SelectFirst[Range[3, 10^4 + 1, 2], SameQ @@ Map[DigitCount[#, 2, 1] &, {n, n #}] &] /. m_ /; MissingQ@ m -> -1, {n, 68}] (* _Michael De Vlieger_, Nov 28 2017 *)

%o (PARI) A057168(n)=n+bitxor(n, n+n=bitand(n, -n))\n\4+n \\ after _M. F. Hasler_ at A057168

%o a(n) = n\=2^valuation(n,2); if (n==1, -1, my(w=(n-1)/2); while(1, w=A057168(w); if((2*w+1)%n==0, return((2*w+1)/n))))

%Y Cf. A000120, A020515, A057168, A077459, A292849.

%K sign,base

%O 1,3

%A _Rémy Sigrist_, Nov 28 2017

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 25 11:39 EDT 2024. Contains 371969 sequences. (Running on oeis4.)