Re: LF: PRIME NUMBERS!


[Prev][Next][Index][Thread]

Re: LF: PRIME NUMBERS!




Of course if you did a simple test for division by 2 and incremented c by 2
you would double the performance.  You also recalculate the square root of
x every iteration when you could have assigned it to a variable.  Also it
appears from inspection that the routine won't work for repeated factors
(i.e. 8=2*2*2) since you don't reinitialize c.  In other words, this
routine is worthless.

-Kevin
khuber@mr.net

Jonathan Dickmann writes:
 > well, here's a prime number finder for the TI-82(never bothered to convert
 > it over to the 92 because of the 'factor(n)' function, and I honestly
 > don't know enough assembly to convert it to that, either(gee, just like
 > most of the people on the list) but it is fairly fast..=20
 > 
 > TI-82 programming:
 > 
 > Input x
 > 2->c
 > Lbl 1
 > If c> sqrt(x)  //sqrt(n) -- take the square root
 > Goto 2
 > If fpart (x/c)=3D0 then x/c -> x // fpart means the part after the decimal
 > Disp c // display the value of c
 > goto 1
 > end // ends if-then statement
 > c+1 -> c
 > goto 1 //if if statement was false, increment c and goto 1
 > lbl 2
 > if x>1 disp x
 > 
 > :end program


Follow-Ups: References: