I'm trying to find the maximum diagonal product of 2 digit numbers in a 20x20 matrix.
This gives an error message :
i <- 17:1
z <- for (j in 1:(18-i))
{b <- max ((x[i,j]*x[i+1,j+1]*x[i+2,j+2]*x[i+3,j+3]))}}
But this doesn't:
z <- for (i <- 17:1)
{for (j in 1:(18-i))
{b <- max ((x[i,j]*x[i+1,j+1]*x[i+2,j+2]*x[i+3,j+3]))}}
but the second version gives me a number too small . Why does the first one not work, i think it would yield the correct answer, but i don't understand the error message.