OFFSET
0,3
LINKS
Antti Karttunen, Table of n, a(n) for n = 0..131072
FORMULA
It seems that a(n) ~ C n/log(n) asymptotically with C = 1.4... (n = 10^6 gives C = 1.469..., n = 10^7 gives C = 1.4614...).
EXAMPLE
17 (= 10001 in binary) -> 15 (= 1111) -> 11 (= 1011) -> 8 (= 1000) -> 7 (= 111) -> 4 (= 100) -> 3 (= 11) -> 1 -> 0, hence a(17)=8.
MATHEMATICA
Table[-1 + Length@ NestWhileList[# - DigitCount[#, 2, 1] &, n, # > 0 &], {n, 0, 75}] (* Michael De Vlieger, Jul 16 2017 *)
PROG
(PARI) for(n=1, 150, s=n; t=0; while(s!=0, t++; s=s-sum(i=1, length(binary(s)), component(binary(s), i))); if(s==0, print1(t, ", "); ); )
(PARI) a(n)=my(k); while(n, n-=hammingweight(n); k++); k \\ Charles R Greathouse IV, Oct 30 2012
(MIT/GNU Scheme)
;; with memoizing definec-macro:
(definec (A071542 n) (if (zero? n) n (+ 1 (A071542 (- n (A000120 n)))))) ;; Antti Karttunen, Oct 24 2012
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Benoit Cloitre, Jun 02 2002
EXTENSIONS
Starting offset changed to 0 with a(0) prepended as 0 by Antti Karttunen, Oct 24 2012
STATUS
approved