Re: LF: PRIME NUMBERS!


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

Re: LF: PRIME NUMBERS!



On Mon, 16 Sep 1996, Jimmy Mårdell wrote:

> that1guy@juno.com wrote:
> > 
> > Could someone PLEASE write a Prime-Number finder for Fargo... Nothing
> > fancy at all, just something that will handle big numbers. I wrote one
> > for ti-basic, but it goes SO SLOW! I think this would be perfect for ASM
> > becuase it goes so fast.
> 
> Not really that necessary since FACTOR( handles very big numbers, but it
> could be cool to see how much faster I/someone else could make it :-)

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.. 

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)=0 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

this runs pretty quickly, I imagine under assembly it would fly.  granted,
this on the 82 vs. factor on the 92 is no contest.  If I have time I'll
try this on the 92 vs. factor on the 92 and see who wins.

Jonathan Dickmann
email jdickman@rhf.bradley.edu



Follow-Ups: References: