You could utilize sin(), it goes from -1 to 1 as well as smoothly inbetween.
So you’d start with
Sin(x)
Shift it over so when x=0 it will be 1
Sin(x+90)
Next change it so it goes from -1 to 1 every 90 instead of 180.
Sin(2*x+90)
You could also use cos() instead. It’s just 90 off from sin()
Cos(2*x)
If you don’t want the smooth transitions inbetween you could utilize some rounding.
Cos(2*round(x/90)*90)
Hope that helps.