Richard in Reading on Fri, 26 Apr 2013 15:57:21 +0200


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

Trying to factor a number a bit but not hanging the program for hours


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?

Cheers!

Richard

PS Thanks to Dirk Laurie for solving my sqrt complaint!