How to replace while with a recursive function?

Viewed 3922

I'm using while in this fashion:

while (value < -180 || value > 180) {
  if (value < -180) {
    value += 360
  }
  if (value > 180) {
    value -= 360
  }
}

I would like, though, to use a recursive function instead of while. I searched on Google but couldn't find anything. So I thought maybe I could get the answer here.

2 Answers
Related