There is a builtin addon for that, no need to reinvent the wheel. Under the User Preferences > Addons make sure Add Mesh : Extra Objects is active.
Then in the 3D viewView simply press Shift + A > Mesh > Extras > Step Pyramid
You can then adjust the builtin parameters as desired.
Only downsides aredownside is that the addon seems to generate pyramids radially, hence a four sided pyramid seems by default rotated 45° about the Z axis in relation to world coordinates, it also is kind of destructive, in the sense that it can't easily be changed or its parameters adjusted after creation.
As mentioned by @batFINGER the Reduce Step By value needs to be twice the value of the Height parameter to obtain "square steps", where the riser matches the tread depth. As pointed out by Andrew Morton, then clarified this is due to the reduction value isbeing applied in relation to shapetotal base diameter, taking into account steps on both sides, rather than an absolute step sizetread depth, thus apparently halved.