unity – Fit in squares in a dedicated space


A random number between 2 and 100, What I want to do is; create a number of squares(doesn’t have to be, any shape is ok) that will fit accordingly inside the dedicated space for them(let’s say half of the screen, etc).

if the number is 2, create 2 squares that are 1/2 space size big. if the number is 10, create 10 squares 1/10 space size big. maximum squares per rows and columns are 10… Example:
enter image description here

How can I achieve something like this, any tutorial or idea?