Wednesday 23 March 2011

Prime Factors - the program

The logic for the prime factors program was presented previously. Here is the logic converted into a program for the fx-50F:-

?→A:2→X:Lbl 1:X→B:While B<A:B+X→B:WhileEnd:If B=A:Then X▲
A÷X→A:Goto 1:IfEnd:X+1→X:If X²>A:Then A▲IfEnd:Goto 1

This is pretty much how the program looks when keyed into the calculator in edit mode except it all appears on one continuous line. Special Program Commands (? → : Lbl While WhileEnd 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, B and X are input using [ALPHA] [A], [B] or [X] keys. The ":" Separator Code command is used frequently and can be alternatively input using the [EXE] key.

This program is 66 steps in length.

No comments:

Post a Comment