Prime Number Test - identifies primes

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.

:Prompt X
:If fPart(X/P)*P=0
:Goto E
:Lbl E
:If Y≠­1
:Disp X
:Disp "Composite"
:Disp "Divisible by"
:Disp Y
:If Y=­1
:Disp X
:Disp "Is prime"

(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-ShareAlike 3.0 License