TI-BASIC:Guess Number

From Learn @ Cemetech
Revision as of 18:20, 24 February 2016 by Maintenance script (talk | contribs) (Initial automated import)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

This program identifies whether a number is prime.

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

PROGRAM: PRIME

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

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

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