# TITLE: Decomposition to prime factors # AUTHOR: Roy F.A. Maclean # EMAIL: rfamgm at gmail # WEB: http://www.spiderpixel.co.uk/caspro # DATE: 10Sep1992, 6Oct1999, 10May2004, 27Oct2006 # MAKE: CASIO # MODEL: fx6300G or greater # SIZE: 94 or 78 # NOTES: Enter a positive integer. The prime factors will be displayed. # This uses the trial division method. # The higher the number to be factored the slower it is. # On an fx9700GE numbers about one million take about 10 seconds. # # There are two versions here. The second version takes up less # memory and is slightly faster but displays the number '1' at the end. @@ Program 1 Lbl 0 ?->A:3->B Lbl 1 Frac .5A<>0=>Goto 2:2_ A/2->A A=1=>Goto 0 Goto 1 Lbl 3:B_ A/B->A Lbl 2 sqrt A->C Lbl 4 B>C=>Goto 5 Frac (A/B)=0=>Goto 3 B+2->B:Goto 4 Lbl 5:A @@ Program 2 ?->A:3->B Lbl 1 Frac .5A<>0=>Goto 2:2_ A/2->A:Goto 1 Lbl 3:B_ A/B->A Lbl 2 sqrt A->C Lbl 4 Frac (A/B)=0=>Goto 3 B+2->B:B<=C=>Goto 4 A