I have a function of k (written in the form of a table/list to get values) for 16 integer values from 1 to 16:
f = Table[3*k*k, {k, 1, 256}]
I want to replace every alternate 4 elements of this list with the number 1.
I want to write a loop but I can't figure out how to do that.
While[Mod[i, 4] == 0, Do[f[i + n] = 1, {n, 1, 4}, i++]]
How would you make this logic work in Mathematica.
To make it more clear the out put of f is
{3, 12, 27, 48, 75, 108, 147, 192, 243, 300, 363, 432, 507, 588, 675, 768,.......}
I want to replace the elements such that
{3, 12, 27, 48, 1, 1, 1, 1, 243, 300, 363, 432, 1, 1, 1, 1,.....,1,1,1,1}
ReplacePart[ Partition[f, 4], {2 -> {1, 1, 1, 1}, 4 -> {1, 1, 1, 1}}] // Flatten
$\endgroup$Flatten@Riffle[Partition[f, 4][[;; ;; 2]], {ConstantArray[1, 4]}]
$\endgroup$