login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Smallest evil number k (member of A001969) such that k*n is also evil.
1

%I #31 Feb 22 2022 12:21:19

%S 3,3,3,3,3,3,9,3,3,3,3,3,3,9,3,3,3,3,3,3,3,3,9,3,3,3,5,9,15,3,33,3,3,

%T 3,3,3,3,3,5,3,3,3,3,3,3,9,3,3,3,3,3,3,3,5,3,9,9,15,3,3,3,33,3,3,3,3,

%U 3,3,3,3,9,3,3,3,3,3,3,5,3,3,3,3,3,3,3,3

%N Smallest evil number k (member of A001969) such that k*n is also evil.

%C All terms are odd since if 2*j and 2*j*n are both evil, then so are j and j*n. - _Michael S. Branicky_, Feb 21 2022

%e For n = 7 both 9 and 9*7 are evil and no smaller multiple of 7 works.

%t evilQ[n_] := EvenQ[DigitCount[n, 2, 1]]; a[n_] := Module[{k = 1}, While[!evilQ[k] || !evilQ[k*n], k++]; k]; Array[a, 100] (* _Amiram Eldar_, Feb 21 2022 *)

%o (Python)

%o def ev(n): return bin(n).count("1")%2 == 0

%o def a(n):

%o k = 3

%o while not (ev(k) and ev(k*n)): k += 1

%o return k

%o print([a(n) for n in range(1, 87)]) # _Michael S. Branicky_, Feb 21 2022

%o (PARI) isevil(m) = !(hammingweight(m) % 2);

%o a(n) = my(k=1); while (!isevil(k) || !isevil(k*n), k++); k; \\ _Michel Marcus_, Feb 22 2022

%Y Cf. A001969, A351835 (analog for the odious numbers A000069).

%Y Cf. A180938 (where k is not necessarily evil).

%K nonn,base

%O 1,1

%A _Jeffrey Shallit_, Feb 21 2022