how make a for loop that makes GUI boxes ?

Hi i want to make a for loop that displays GUI boxes whatever the amount is

MyCode

public void LootAmountRandomizer()
	{
		LootAmount = Random.Range(0,100);
		
		
		if(LootAmount<=50)
		{
		Debug.Log("3 items");
		LootSlots = 3;
		}
		else if (LootAmount<=75)
		{
		Debug.Log("4 items");	
		LootSlots = 4;
		}
		else if(LootAmount<=90)
		{
		Debug.Log("5 items");	
		LootSlots = 5;
		}
		else if(LootAmount<=100)
		{
		Debug.Log("6 items");
		LootSlots = 6;
		}
	
	}

Start with a sample code like the one below, and then tune it to your needs.

void OnGUI()
{
    for(int i = 0; i < LootSlots; i++)
    {
        GUI.Box(new Rect(i * 40, 0, 40, 40), i.ToString());
    }
}