Primes ’n’ Digits
Jelly, 18 17 bytes
-1 byte thanks to caird coinheringaahing & H.PWiz (avoid pairing the two vectors)
DF‘ċЀ⁵
ÆfQÇæ.Ç‘$
A monadic link taking a positive integer and returning a non-negative integer.
Try it online!
How?
DF‘ċЀ⁵ - Link 1, digitalCount: number(s) e.g. [13,17]
D - to decimal list (vectorises) [[1,3],[1,7]]
F - flatten [1,3,1,7]
‘ - increment (vectorises) [2,4,2,8]
⁵ - literal ten 10
Ѐ - map across (implicit range [1,2,3,4,5,6,7,8,9,10])
ċ - count [0,2,0,1,0,0,0,1,0,0]
ÆfQÇæ.Ç‘$ - Main link: positive integer, n e.g. 11999
$ - last two links as a monad:
Ç - call the last link (1) as a monad [0,2,0,0,0,0,0,0,0,3]
‘ - increment (vectorises) [1,3,1,1,1,1,1,1,1,4]
Æf - prime factorisation [13,13,71]
Q - deduplicate [13,17]
Ç - call the last link (1) as a monad [0,2,0,1,0,0,0,1,0,0]
æ. - dot product 8
APL (Dyalog), 43 41 bytes
⎕CY'dfns'
+/×/+/¨⎕D∘.=⍕¨(⎕D,r)(∪3pco r←⎕)
Try it online!
How?
r←⎕
- input into r
3pco
- prime factors
∪
- unique
⎕D,r
- r
prepended with 0-9
⍕¨
- format the factors and the prepended range
⎕D∘.=
- cartesian comparison with every element of the string 0123456789
+/¨
- sum each row of the two tables formed
×/
- multiply the two vectors left
+/
- sum the last vector formed
Jelly, 16 bytes
ṾċЀØD
ÆfQÇ×Ç‘$S
Try it online!
Developed independently from and not exactly the same as the other Jelly solution.
Explanation
I'm gong to use 242
as an example input.
ṾċЀØD Helper link
Ṿ Uneval. In this case, turns it's argument into a string.
242Ṿ → ['2','4','2']. [2,11] → ['2', ',', '1', '1']. The ',' won't end up doing anything.
ØD Digits: ['0','1',...,'9']
ċЀ Count the occurrence of €ach digit in the result of Ṿ
ÆfQÇ×Ç‘$S Main link. Argument 242
Æf Prime factors that multiply to 242 → [2,11,11]
Q Unique elements → [2,11]
Ç Apply helper link to this list → [0,2,1,0,0,0,0,0,0,0]
Ç‘$ Apply helper link to 242 then add 1 to each element → [1,1,3,1,2,1,1,1,1,1]
× Multiply the two lists element-wise → [0,2,3,0,0,0,0,0,0,0]
S Sum of the product → 5