[Solved] Function returns quadratic matrix in R [closed]
You were almost there. you just had to specify n and return the right object at the end. matrix_a = function(n) { A = matrix(data = 0, nrow = n, ncol = n) for (i in 1:n) { for (j in 1:n) { if (i>=j) {A[i,j] = (i^2)} if (i<j) {A[i,j] = (j^2)} } } … Read more