Skip to main content
added 40 characters in body
Source Link
m_goldberg
  • 108.6k
  • 16
  • 107
  • 263

Consider

sum[f_sumOverPrimes[f_, n_Integer /; n > 1] :=  Total @ Table[f[Prime[i]], {i, 1, PrimePi[n]}] 

With this function,

sum[fsumOverPrimes[f, 18] 

f[2] + f[3] + f[5] + f[7] + f[11] + f[13] + f[17]

and

sum[2^#1 + sumOverPrimes[#^2 + 1 &, 10]6] 

17642

Consider

sum[f_, n_Integer /; n > 1] := Total @ Table[f[Prime[i]], {i, 1, PrimePi[n]}] 

With this function,

sum[f, 18] 

f[2] + f[3] + f[5] + f[7] + f[11] + f[13] + f[17]

and

sum[2^# + 1 &, 10] 

176

Consider

sumOverPrimes[f_, n_Integer /; n > 1] :=  Total @ Table[f[Prime[i]], {i, 1, PrimePi[n]}] 

With this function,

sumOverPrimes[f, 18] 

f[2] + f[3] + f[5] + f[7] + f[11] + f[13] + f[17]

and

1 + sumOverPrimes[#^2 + 1 &, 6] 

42

Source Link
m_goldberg
  • 108.6k
  • 16
  • 107
  • 263

Consider

sum[f_, n_Integer /; n > 1] := Total @ Table[f[Prime[i]], {i, 1, PrimePi[n]}] 

With this function,

sum[f, 18] 

f[2] + f[3] + f[5] + f[7] + f[11] + f[13] + f[17]

and

sum[2^# + 1 &, 10] 

176