Wednesday, 24 October 2012

Is it prime - the program

I discussed the logic for this program in a previous blog. Here is the logic converted into a program for the fx-50F:-


Lbl 0:?→X:If X≥37²:Then 999→Y:Goto 2:IfEnd:X≥11=>Goto 1:
0→Y:X=2=>1→Y:X=3=>1→Y:X=5=>1→Y:X=7=>1→Y:Goto 2:Lbl 1:πX→A:
1→Y:sin(A÷2)=0=>0→Y:sin(A÷3)=0=>0→Y:sin(A÷5)=0=>0→Y:
sin(A÷7)=0=>0→Y:Y=0=>Goto 2:X<121>Goto2:
sin(A÷11)=0=>0→Y:sin(A÷13)=0=>0→Y:sin(A÷17)=0=>0→Y:
sin(A÷19)=0=>0→Y:Y=0=>Goto 2:X<329>Goto2:
sin(A÷23)=0=>0→Y:sin(A÷29)=0=>0→Y:sin(A÷31)=0=>0→Y:
Lbl 2:Y▲Goto 0:

This is pretty much how the program looks when keyed into the calculator in edit mode. Special Program Commands (? → => : Lbl = < ≥ If Then IfEnd ▲ Goto) are input using the [SHIFT] [P-CMD] keys. The cursor key (marked Replay) is used to switch between various screens of commands. Memory variables A, X and Y are input using [ALPHA] [A], [X] etc keys. The ":" Separator Code command is used frequently and can be alternatively input using the [EXE] key.

This program is 264 steps in length.

No comments:

Post a Comment