d[e[n_]] := d[e[n]] = Total[f /@  (n-Most@NestWhileList[NextPrime, 2, #<n&])]

d[e[100]]

d/@Array[e, {1000}];

Timing[d/@Array[e, {1000}];]

Timing[Total[d/@Array[e, {1000}]];]

Timing[t0=Sum[Round@Log[k]e[k], {k, 1000}] /. e[n_] :> d[e[n]];]

Timing[t0=Expand[t0];]

Timing[t1=Expand[Sum[Round@Log[k]e[k], {k, 1000}] /. e[n_] :> d[e[n]]];]

t0==t1

Timing[t2=Sum[Expand[Round@Log[k]d[e[k]]], {k, 1000}];]

t1==t2

Timing[t3=Total[Expand /@ (Table[Round@Log[k]e[k], {k,1000}] /. e[n_] :> d[e[n]])];]

t2==t3