Re: QuickFactorInteger
- To: mathgroup at smc.vnet.net
- Subject: [mg108476] Re: QuickFactorInteger
- From: Daniel Lichtblau <danl at wolfram.com>
- Date: Fri, 19 Mar 2010 02:48:50 -0500 (EST)
Scott Hemphill wrote: > Artur <grafix at csl.pl> writes: > >> Dear Mathematica Gurus >> Who know how write procedure which will be do brutal force stop >> FactorInteger after defined time (e.g. 30 second) but results finded up >> to 30 second should be listed >> Best wishes >> Artur >> >> Option Automatic need about 75 second to stop >> >> Timing[fax = >> FactorInteger[ >> 1111111111111111111111111111111111111111111111111111111111111111111\ >> 1111111111111111111111111111111111111111111111111111111111111111111111\ >> 1111111111111111111111111111111111111111111111111111111111111111111111\ >> 11111111111111111111111111111111111119, Automatic]] > > I believe that large integer is x = (10^245+71)/9. > > If you let FactorInteger[x, 2] run long enough, you find out that x is > divisble by 24164822890633570718420181256194871. > > Scott This gives the basic idea for how to do what was wanted. Wrap repeated calls of FactorInteger[..., 2] inside a TimeConstrained[loop,time,failexpr], keeping track of all factors found, which are PrimeQ, (so as to further attempt to factor those that are not). Put the ones found in failexpr. When time finally elapses, they get returned. if you fully factor the number before time expires, return factors the usual way. Daniel Lichtblau Wolfram Research