%I #19 May 23 2022 17:22:25
%S 0,1,3,5,7,8,12,13,15,31,63,88,127,129,131,244,255,262,263,288,300,
%T 344,511,793,914,1012,1023,1045,1116,1196,1538,1549,1565,1652,1817,
%U 1931,1989,2047,2067,2096,2459,2548,2862,2918,2961,3372,3478,3540,3588,3673,3707
%N Numbers k such that k! and (k+1)! have the same binary weight (A000120).
%C Numbers k such that A079584(k) = A079584(k+1).
%C The corresponding values of A079584(k) are 1, 1, 2, 4, 6, 6, 12, 12, 18, 42, ...
%C This sequence is infinite as it contains A000225. - _Rémy Sigrist_, May 23 2022
%H Amiram Eldar, <a href="/A354300/b354300.txt">Table of n, a(n) for n = 1..1000</a>
%e 1 is a term since A079584(1) = A079584(2) = 1.
%e 3 is a term since A079584(3) = A079584(4) = 2.
%t s[n_] := s[n] = DigitCount[n!, 2, 1]; Select[Range[0, 4000], s[#] == s[# + 1] &]
%o (Python)
%o from itertools import count, islice
%o def wt(n): return bin(n).count("1")
%o def agen(): # generator of terms
%o n, fn, fnplus, wtn, wtnplus = 0, 1, 1, 1, 1
%o for n in count(0):
%o if wtn == wtnplus: yield n
%o fn, fnplus = fnplus, fnplus*(n+2)
%o wtn, wtnplus = wtnplus, wt(fnplus)
%o print(list(islice(agen(), len(data)))) # _Michael S. Branicky_, May 23 2022
%o (PARI) isok(k) = hammingweight(k!) == hammingweight((k+1)!); \\ _Michel Marcus_, May 23 2022
%Y A354301 is a subsequence.
%Y Cf. A000120, A000142, A000225, A079584, A353986.
%K nonn,base
%O 1,3
%A _Amiram Eldar_, May 23 2022
|