Prime Number Test - identifies primes
toolbar-separator.png This page has been deleted from the main contents of the wiki, and moved to the deleted: namespace as a record of its contents. Rather than adding content to this page, please put it somewhere where it will actually have a use. In addition, please avoid linking to this page.

This program identifies whether a number is prime.

NOTE: This program does not display a correct result for 0, 1, or 2, which are special cases.

PROGRAM: PRIME
:ClrHome
:Prompt X
:­1→Y
:For(P,2,√(X)+1)
:If fPart(X/P)*P=0
:Then
:P→Y
:Goto E
:End
:End
:Lbl E
:If Y≠­1
:Then
:Disp X
:Disp "Composite"
:Disp "Divisible by"
:Disp Y
:End
:If Y=­1
:Then
:Disp X
:Disp "Is prime"
:End

(If you plan to copy and paste this string of code into a program editor remember to remove the colons.)

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 2.5 License.