ISPRIME: #This uses the For statement

```
:Input "NUM:",X
:startTmr->B
:0
:For(A,2,Sqrt(X
:If not(fPart(X/A:Return
:End
:1
:Disp checkTmr(B
```

ISPRIME2: #This uses the While statement

```
:Input "NUM:",X:abs(X->X
:1+int(Sqrt(X->Z
:startTmr->B
:2->A
:0
:While A<Z
:If not(fPart(X/A:Return
:A+1->A
:End
:1
:Disp checkTmr(B
```

Now, while it's great that While is faster as X gets larger, I'd like to know why exactly this happens, especially when For is supposed to be faster for this kind of operation.

Results:

ISPRIME [1003001]

Time = 59 Seconds

ISPRIME2 [1003001]

Time = 30 Seconds