login
Total number of holes in decimal expansion of the number n, assuming 4 has no hole.
9

%I #21 Nov 18 2022 18:09:03

%S 1,0,0,0,0,0,1,0,2,1,1,0,0,0,0,0,1,0,2,1,1,0,0,0,0,0,1,0,2,1,1,0,0,0,

%T 0,0,1,0,2,1,1,0,0,0,0,0,1,0,2,1,1,0,0,0,0,0,1,0,2,1,2,1,1,1,1,1,2,1,

%U 3,2,1,0,0,0,0,0,1,0,2,1,3,2,2,2,2,2,3,2,4,3,2,1,1,1,1,1,2,1,3,2,2,1,1,1,1

%N Total number of holes in decimal expansion of the number n, assuming 4 has no hole.

%C Assumes that 4 is represented without a hole.

%H Indranil Ghosh, <a href="/A064532/b064532.txt">Table of n, a(n) for n = 0..50000</a>

%F a(10i+j) = a(i) + a(j), etc.

%e 8 has two holes so a(8) = 2.

%t a[n_ /; 0 <= n <= 9] := a[n] = {1, 0, 0, 0, 0, 0, 1, 0, 2, 1}[[n + 1]]; a[n_] := Total[a[#] + 1 & /@ (id = IntegerDigits[n])] - Length[id]; Table[a[n], {n, 0, 104}] (* _Jean-François Alcover_, Nov 22 2013 *)

%t Table[DigitCount[x].{0, 0, 0, 0, 0, 1, 0, 2, 1, 1}, {x, 0, 104}] (* _Michael De Vlieger_, Feb 02 2017, after _Zak Seidov_ at A064692 *)

%o (Python)

%o def A064532(n):

%o x=str(n)

%o return x.count("0")+x.count("6")+x.count("8")*2+x.count("9") # _Indranil Ghosh_, Feb 02 2017

%o (PARI) h(n) = [1, 0, 0, 0, 0, 0, 1, 0, 2, 1][n];

%o a(n) = if (n, my(d=digits(n)); sum(i=1, #d, h(d[i]+1)), 1); \\ _Michel Marcus_, Nov 11 2022

%Y Cf. A064529, A064530. Equals A064531 - 1.

%Y Cf. A358439 (sum by number of digits).

%K nonn,easy,base

%O 0,9

%A _N. J. A. Sloane_, Oct 07 2001

%E More terms from _Matthew Conroy_, Oct 09 2001