Tandy EC-4020 calculator programmes

From Wikistix

Bunch of little programmes I've written for my old Tandy EC-4020 programmable calculator (a re-badged Casio fx-4000P).

Calculate π

Calculate π using the Gauss–Legendre algorithm. Converges past the calculators accuracy in about 3 iterations.

1→A:√2-1→B:4-1→T:1→P:
Lbl 0:(A+B)÷2→G:√(AB)→B:T-P(A-G)²→T:2P→P:G→A:(A+B)²÷4÷T◢Goto 0

Prime Factors

Report the prime factors of a given number.

Mcl:
Lbl 0:"M":?→A:Goto 2:
Lbl 1:2◢A÷2→A:A=1⇒Goto 9:
Lbl 2:Frac (A÷2)=0⇒Goto 1:3→B:
Lbl 3:√A+1→C:
Lbl 4:B≥C⇒Goto 8:Frac (A÷B)=0⇒Goto 6:
Lbl 5:B+2→B:Goto 4:
Lbl 6:A÷B×B-A=0⇒Goto 7:Goto 5:
Lbl 7:B◢A÷B→A:Goto 3:
Lbl 8:A◢
Lbl 9:"END"◢Goto 0