Bill Allombert on Sat, 25 Nov 2006 22:55:51 +0100


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

Re: Two factor questions


On Sat, Nov 25, 2006 at 09:20:20PM -0000, Nick Hobson wrote:
> Hi,
> 
> I have a couple of questions about the factor function, as applied to  
> integers.
> 
> 1) Does it sort the results by prime (i.e., first column)?  All the  
> results I've seen have been sorted, but I notice the manual doesn't  
> specify this behavior.  (Unless I'm missing something.)

Yes. (beware that for negative numbers the first line is [-1,1]).

> 2) Is it possible to request only the smallest prime factor, rather than a  
> complete factorization?

Not really. The only algorithm available in PARI that can _prove_ a factor
is the smallest is trial division, and there are no toggle in place to stop
trial division at the first hit. However you can easily implement that
yourself using the prime number table.

On the other hand, if you want a small prime factor without a proof it is 
the smallest, then it is possible at least in library mode.

Cheers,
Bill.