Prime Number - identifies primes

This program identifies whether a number is prime.

NOTE: this program cannot handle 0, 1, or 2, which are special cases.

:Prompt X
:-1 -> Y
:For(P,2,sqrt(X) + 1)
:If fPart(X/P) * P = 0
:P -> Y
:Goto E
:Lbl E
:If Y does not = -1

([Use the symbol does not equal, located in the [Test] menu accessed by pressing [2nd] [MATH])

:Disp X
:Disp "Is not prime"
:Disp "Divideable by"
:Disp Y
:If Y = -1
:Disp X
:Disp "Is prime"


Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License