I have a list:
G[3] = {2, 4, 2, 4, 2, 4, 2, 4, 2, 4}
(there's a 3 in there for the 3rd Prime)
Recursively defined by:
G[2] = {2,4}
G[i_] := Nest[Join[#, G[i - 1]] &, G[i - 1], Prime[i] - 1]
And I would like to transform it into the list
Hsum[3]= {2, 6, 4, 2, 4, 2, 4, 6}
to get the ith element of the second list, I add up elements 1 to i of the original list and test if the sum is = 1 (mod 5) then I replace G[3][[i]]
with G[3][[i]]+G[3][[i+1]]
and delete element G[3][[i+1]]
So far, all I can get to work is the summing and testing mod some prime.
Hsum[i_] :=
Table[If[Mod[Sum[G[i][[j]], {j, 1, k}], Prime[i]] == 1,
G[i][[k]] + G[i][[k - 1]], G[i][[k]]], {k, 1, Length[G[i]]}]
but that doesn't get rid of the unwanted element that has been summed.
Any help would be appreciated!