For a positive integer n, return an nXn matrix mat such that the value of each element in row i and column j is given according to the following rules:
If n is not a positive integer, mat should be an empty matrix.
Examples:
Input: n = 4 Output: mat = [0 1 2 3 1 0 1 2 2 1 0 1 3 2 1 0]
Input: n = -2 Output: mat = []
Input: n = 2.5 Output: mat = []
Project Euler: Problem 5, Smallest multiple
241 Solvers
The Answer to Life, the Universe, and Everything
312 Solvers
551 Solvers
Matlab Basics II - Create a vector with a repeated entry
137 Solvers
Separate even from odd numbers in a vector - without loops
75 Solvers
Problem Tags