Frn: Anders Tiberg <anders.tiberg@telia.com>
Till: <filearchive@ticalc.org>
mne: Factorer
Datum:  den 4 mars 2009 21:30


          
      Program Factorer v1.21 written by Anders Tiberg.



This program is based on a primefactorprogram and consequently
removes the primenumbers as they are found.To obtain the correct
number of combinations in between them, the augment instruction
is used.


 Factorer v1.21
:ClrHome
:Disp "FACTORS INTEGERS
:Input X
:X->Z
:{1->L1
:2->P
:While not(fPart(X/2
:Lbl 1
:X/P->X
:If fPart(max(L1)/P
:L1->L2
:augment(L2,PL1->L1
:End
:For(P,P+(P>2)+1,\/(X),2        (the squareroot of X)
:While not(fPart(X/P
:Goto 1
:End
:End
:DelVar L2
:If X>1
:augment(L1,XL1->L1
:SortA(L1
:Disp Z,"",dim(L1
:L1


As comparison an ordinary factorprogram below.


 Facts
:ClrHome
:Prompt X
:X->Z
:0->I
:{1}->L1
:2+(0~fPart(X/2)->F        (if 0 differs from)
:For(F,F,\/(X),F-1
:If not(fPart(X/F
:Then
:I+2->I
:X/F->L1(I-1
:F->L1(I-(F^2=X) 
:End
:End
:SortA(L1
:Disp Z,"",dim(L1
:L1


The number 9,699,690 takes about 10 seconds for Factorer,while
Facts runs in round one and a half minute.

     
         
       Questions and/or input, mailto: anders.tiberg@telia.com




 