Euler problem 11.4

```
recursive function max_e11(a2d, i, j, acc) result(a)

integer, dimension(20, 20) :: a2d
integer :: i, j, acc, a, accm = 0
integer :: dia_l = 0, dia_r = 0, hori = 0, vert = 0
integer :: k = 0, x = 1, y = 1
integer :: lenx = 20, leny = 20

if (i <= (lenx - 3)) then
hori = 1
do k = 0, 3
hori = hori*a2d(i+k, j)
end do
end if

if (j <= (leny - 3)) then
vert = 1
do k = 0, 3
vert = vert*a2d(i, j+k)
end do
end if

if ((i <= (lenx - 3)) .and. (j <= (leny - 3))) then
dia_r = 1
do k = 0, 3
dia_r = dia_r*a2d(i+k, j+k)
end do
end if

if ((i >= 4) .and. (j <= (leny - 3))) then
dia_l = 1
do k = 0, 3
dia_l = dia_l*a2d(i-k, j+k)
end do
end if

if ((i == lenx) .and. (j == leny)) then
a = acc
else
accm = max(acc, hori, vert, dia_l, dia_r)

if (i == lenx) then
x = 1
y = j + 1
else
x = i + 1
y = j
end if

a = max_e11(a2d, x, y, accm)
end if
end function max_e11

program main

implicit none

integer :: p_max, p_count, i, j
integer(kind = 16) :: p_sum
logical, ALLOCATABLE, DIMENSION(:) :: is_prime
character(len=128) :: currentDir
integer, dimension(20, 20) :: D, M
integer :: max_e11

call GET_ENVIRONMENT_VARIABLE('PWD', currentDir)

print *, "dir == ", trim(currentDir)

open(1, file = "t.txt", status = "old")
close(1)

M = transpose(D)

write(*, *) M(1, 1)
write(*, *) max_e11(M, 1, 1, 0)
write(*, *) M(1, 1)

end program main
```

— Me@2022-12-24 11:50:15 AM

.

.