v: number of iterations
function gauss_seidel_mg(nx, ny, dx, dy, f, un, V)
rt = zeros(Float64, nx+1, ny+1) # temporary variable
den = -2.0/dx^2 - 2.0/dy^2
for iteration_count = 1:V
for j = 2:nx for i = 2:ny
rt[i,j] = f[i,j] - (un[i+1,j] - 2.0*un[i,j] + un[i-1,j])/dx^2
un[i,j] = un[i,j] + rt[i,j]/den
end end
end
end
```


**Listing 26.** Implementation of multigrid framework in Julia with two levels in V-cycle. ✞ ☎

```