Write a method which will tell me the efficinent order of a matrix (X*Y), where i can store n elements. Following the condition,
1. After storing n elements in that matrix, it should not have more than 2 empty spaces/blocks left.
2. the order/size of the matrix should be nearer to a square matrix size. i.e. try to create the matrix, either of square matrix or a rectagonal matrix but nearer to a square matrix.
For n=4, X=2, Y=2
For n=23, X=5, Y=5
For n=22, X=4, Y=6 or X=6, Y=4
For n=21, X=3, Y=7 or X=7, Y=3