login
Least positive multiple of n written in base 7 using only 0 and 1.
2

%I #29 Jan 31 2024 16:48:08

%S 1,11,111,11,101,111111,10,11,1011,101,10011,111111,1011,110,11001,

%T 1111,100111,1101111,111,1111,1110,11101,101011,111111,101,111001,

%U 1011,110,1111111,1011111,100111,11011,10011,100111,1010,1101111

%N Least positive multiple of n written in base 7 using only 0 and 1.

%H Harvey P. Dale, <a href="/A004287/b004287.txt">Table of n, a(n) for n = 1..1000</a>

%t With[{cl=Rest[{FromDigits[#,7],FromDigits[#]}&/@Tuples[{0,1},7]]},Table[ SelectFirst[ cl,Mod[#[[1]],n]==0&],{n,40}]][[;;,2]] (* _Harvey P. Dale_, Jan 31 2024 *)

%o (Python)

%o def A004287(n):

%o if n > 0:

%o for i in range(1,2**n):

%o s = bin(i)[2:]

%o if not int(s,7) % n:

%o return int(s)

%o return 0 # _Chai Wah Wu_, Dec 30 2014

%Y Cf. A244958 (written in base 10).

%K nonn,base

%O 1,2

%A _David W. Wilson_

%E Removed initial 0 since (1) it did not match the definition, and (2) there are many similar sequences with the same author which also say "positive". Also changed offset. - _N. J. A. Sloane_, Jan 31 2024

%E Previous b-file replaced by _Harvey P. Dale_, Jan 31 2024