A178757 Smallest k such that k*n has an odd number of 1's in its base-2 expansion.
1, 1, 7, 1, 5, 7, 1, 1, 9, 5, 1, 7, 1, 1, 19, 1, 17, 9, 1, 5, 1, 1, 3, 7, 1, 1, 3, 1, 3, 19, 1, 1, 33, 17, 1, 9, 1, 1, 3, 5, 1, 1, 7, 1, 9, 3, 1, 7, 1, 1, 7, 1, 5, 3, 1, 1, 3, 3, 1, 19, 1, 1, 67, 1, 65, 33, 1, 17, 1, 1, 3, 9, 1, 1, 5, 1, 5, 3, 1, 5, 1, 1, 5, 1, 5, 7, 1, 1, 5, 9, 1, 3, 1, 1, 3, 7, 1, 1, 11, 1
Offset: 1
Examples
For n = 3 the sequence has value 7, since 21 is 10101 in base 2, with an odd number of 1's, and no smaller multiple works.
Links
- Michel Marcus, Table of n, a(n) for n = 1..10000
- Johannes F. Morgenbesser, Jeffrey Shallit, Thomas Stoll, Thue-Morse at multiples of an integer, Journal of Number Theory, Volume 131, Issue 8, August 2011, Pages 1498-1512.
Programs
-
Mathematica
f[n_] := Block[{k = 1}, While[ EvenQ@ DigitCount[k*n, 2, 1], k++ ]; k]; Array[f, 105] (* Robert G. Wilson v, Sep 29 2010 *)
-
PARI
a(n) = {my(k = 1); while (hammingweight(k*n) % 2 != 1, k++); k;} \\ Michel Marcus, Jan 23 2016
-
Python
def a(n): k = 1 while not bin(k*n).count("1")%2 == 1: k += 1 return k print([a(n) for n in range(1, 81)]) # Michael S. Branicky, Feb 22 2022
Comments