Bill Allombert on Fri, 26 Apr 2013 16:11:39 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Trying to factor a number a bit but not hanging the program for hours |
On Fri, Apr 26, 2013 at 02:57:11PM +0100, Richard in Reading wrote: > As part of a pari program I'm trying to factor certain large numbers but then give up if a factorization isn't easily achievable. I've been using factorint(n,9) with the expectation that it will always complete reasonably quickly. > > However > > factorint(19841096725703655581869366691520038810629264428011560812788963464047306742065927607422529,9) > > runs for hours whereas > > factorint( 450448646198249 * 7187991967803917, 9) > [3237821250781162225771540741333 1] > > returns straight away even though I'm supplying a composite. > Note that factor() returns the above factors in about 0.2 of a second. > > It would be nice to have a decent factoring function which spends a certain > amount of time trying to factor a number and then gives up. I seem to > remember seeing a script on the web which could do it in pari using the > default factoring function but using some function in combination with trap > to interrupt its execution after a time. > Can anyone help? See ??alarm Cheers, Bill.