OFFSET
1,3
COMMENTS
The Hamming weight of a number n is given by A000120(n).
All terms are odd.
Numbers n such that a(n) is not squarefree are 33, 57, 63, 66, 83, 114, 115, 126, 132, 153, 155, ...
Numbers n such that a(n) > n are 5, 9, 17, 25, 27, 29, 33, 41, 65, 97, 101, 109, 113, ...
a(n) = 1 iff n = 2^i for some i >= 0.
a(n) = 3 iff n = A007583(i) * 2^j for some i > 0 and j >= 0.
Apparently:
- if n < 2^k then a(n) < 2^k,
- a(n) = n iff n = A000225(i) for some i > 0.
Proof that a(n) < 2^k if n < 2^k (see preceding comment): We can assume that n is not a power of two and take k such that 2^(k-1) < n < 2^k (so that k is the number of binary digits of n). Now, n - 1 and 2^k - n have complementary binary digits, so the binary digits of (2^k - 1)*n = 2^k*(n - 1) + (2^k - n) consist of the k digits of n - 1 followed by the complementary digits. This implies that the number of binary 1's is k, so that (2^k - 1)*n and 2^k - 1 have the same number of 1's and a(n) <= 2^k - 1. - Pontus von Brömssen, Jan 01 2021
See also A180012 for the base 10 equivalent sequence.
LINKS
Rémy Sigrist, Table of n, a(n) for n = 1..10000
Altug Alkan, Line graph of n - a(n) for n <= 2^20 + 1
Rémy Sigrist, Scatterplot of n XOR a(n) for n <= 2^16
FORMULA
a((2^m)*n) = a(n) for all m >= 0 and n >= 1.
a(2^m + 1) = 2^(m + 1) - 1 for all m >= 0.
a(2^m - 1) = 2^m - 1 for all m >= 1.
a(2^m) = 1 for all m >= 0.
MATHEMATICA
Table[SelectFirst[Range[1, 2^8 + 1, 2], Equal @@ Thread[DigitCount[{#, # n}, 2, 1]] &], {n, 74}] (* Michael De Vlieger, Sep 25 2017 *)
PROG
(PARI) a(n) = forstep(k=1, oo, 2, if (hammingweight(k) == hammingweight(k*n), return (k)))
(PARI) a(n)=my(k=1); while ((hammingweight(k)) != hammingweight(k*n), k++); k;
CROSSREFS
KEYWORD
AUTHOR
Rémy Sigrist and Altug Alkan, Sep 25 2017
STATUS
approved