PE 49 solution. Takes about 1.1s.
Rice PE 49: only calculate digits once per first-elt.

Saves about 0.2s.
Rice PE 49: only calculate digits if thrd is prime.

Saves about 0.4s; total time now about 0.51s.
PE 50: reproduce given result.
PE 50: get desired answer.