you can use Iterators.product
:
s = 0
for (i1,i2,i3,i4) in Iterators.product(1:4, 1:4, 1:4, 1:4)
s += i1 + i2 + i3 + i4
end
s
or with an arbitrary number of nested loops:
N = 4
s = 0
for i in Iterators.product(fill(1:4, N)...)
s += sum(i)
end
s