How to make Creating prefabs with a for loop in the editor

if (GUI.Button(new Rect(0, 0, position.width, 40), "Instantiate Prefab"))
{
Selection.activeObject = PrefabUtility.InstantiatePrefab(Selection.activeObject as GameObject);
}

There is such a code. As much as I want to use a loop How can I create a prefab?

(I used google translate. I'm sorry if I'm wrong)

8676540--1169463--upload_2022-12-20_18-15-38.png
8676540--1169463--upload_2022-12-20_18-15-38.png

Any kind of loop or code constructs works precisely the same in editor mode as in the game.

https://docs.unity3d.com/ScriptReference/PrefabUtility.html