Suppose that a list can be generated for a sum of primes as follows:
g[n_]:= g[n]= Sum[Prime[j], {j, n}];
lst = Table[g[n], {n, 1, 1000}];
Now that a list has been created what is an efficient way to select values at Lucas number positions ? The result should read {2, 10, 17, 58, ...}
. I have tried several version of Select,
Select[Range[10], Extract[ LucasL[#]][ lst[[#]] ] &]
Select[Range[10], Pick[ lst[[#]], LucasL[#] ] &]
and all lead to empty results.
For context: The calculation process above was/is an attempt to speed up the sum
f[n_]:= f[n]= Sum[Prime[i], {i, LucasL[n]}];
Table[f[n], {n,1,50}]
Any ideas on how to select data from particular positions or how to speed up the calculation of the series would be most helpful.
lst[[Table[LucasL[n], {n, 1, 10}]]]
? $\endgroup$lst[[LucasL@Range@10]]
orExtract[lst, LucasL[List /@ Range[10]]]
orExtract[lst, List /@ LucasL[Range@10]]
? $\endgroup$g
onLucasL[Range@10]
(that is,g /@ LucasL[Range@10]
), instead of generating a larger table and filtering it. $\endgroup$