Given an degree θ, the following code will return the reference angle in Ans:

```
:Prompt θ
:{θ,180-θ,θ-180,360-θ
:Ans(1+int(θ/90
:Disp Ans
```

I used the list data type to compress all the quadrants into a single line. Of course you also could use If statements, but it would be a bit longer.

I hope this helps.

To enable negative degrees as well, use this code with an extra line instead:

```
:Prompt θ
:θ+360(θ<0→θ
:{θ,180-θ,θ-180,360-θ
:Ans(1+int(θ/90
:Disp Ans
```

Edit: If the program should also be able to handle degrees greater than 360 or less then -360, you can take advantage of the modulo function, which only exists on the newer OSs as the remainder( function. If you do not have the latest OS, you can achieve **A mod B** (remainder(A,B)) by **B x fPart(A/B)**

I do not have my TI 84 here at the moment, so I cannot look, how remainder( handles negative numbers, and therefore I am not able to optimize the code that much, but it should look similar to this:

If nothing else works for negative numbers less than -360, you maybe want to use this:

`:1-2(θ<0)remainder(abs(θ),360→θ`

So:

```
:Prompt θ
:1-2(θ<0)remainder(abs(θ),360→θ
:θ+360(θ<0→θ
:{θ,180-θ,θ-180,360-θ
:Ans(1+int(θ/90
:Disp Ans
```