# Primes ’n’ Digits

## Jelly,  18  17 bytes

-1 byte thanks to caird coinheringaahing & H.PWiz (avoid pairing the two vectors)

DF‘ċÐ€⁵
$- 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