login
Number of digits of n which are divisors of n.
8

%I #27 Mar 04 2023 15:40:03

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

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

%U 0,1,1,1,0,0,1,0,2,0,0,1,1,1,0,1,1,0,0,2,0,1,1,1,1,0,1,1,0,0,2,1,2,2,1,2,2

%N Number of digits of n which are divisors of n.

%C a(A038772(n)) = 0; a(A038770(n)) > 0.

%H Reinhard Zumkeller, <a href="/A038769/b038769.txt">Table of n, a(n) for n = 1..10000</a>

%e a(35)=1 because 5 is a divisor of 35 but 3 is not.

%p f:= proc(n) local L; L:= convert(n,base,10);

%p nops(select(t -> t > 0 and n mod t = 0, L))

%p end proc:

%p map(f, [$1..1000]); # _Robert Israel_, Jul 04 2016

%t Array[Count[Position[Most@ DigitCount@ #, _?(# > 0 &)][[All, 1]], k_ /; Mod[#, k] == 0] &, 105] (* _Michael De Vlieger_, Dec 23 2019 *)

%t Table[Count[n/Select[IntegerDigits[n],#>0&],_?IntegerQ],{n,110}] (* _Harvey P. Dale_, Mar 04 2023 *)

%o (Haskell)

%o import Data.Char (digitToInt)

%o a038769 n = length $ filter (== 0)

%o $ map ((mod n) . digitToInt) $ filter (> '0') $ show n

%o -- _Reinhard Zumkeller_, Jun 19 2011

%o (Magma) [#[c:c in Intseq(k) |not IsZero(c) and k mod c eq 0]:k in [1..105]]; // _Marius A. Burtea_, Dec 23 2019

%Y Cf. A034709, A034837, A038770, A038772.

%K nonn,base,easy

%O 1,11

%A _Henry Bottomley_, May 04 2000