The task is to find a non-trivial factor of a composite number.
Write code that finds a non-trivial factor of a composite number as quickly as possible subject to your code being no more than 140 bytes long. The output should just be the factor you have found.
Your code can take input and give output in any way that is convenient including for example as arguments to a function.
Test cases which list all the factors (you only need to output one)
187: 11 17 1679: 23 73 14369648346682547857: 1500450271 9576890767 34747575467581863011: 3628273133 9576890767 52634041113150420921061348357: 2860486313 5463458053 3367900313 82312263010898855308580978867: 264575131106459 311111111111113 205255454905325730631914319249: 2860486313 71755440315342536873 1233457775854251160763811229216063007: 1110111110111 1000000000063 1111111999999 1751952685614616185916001760791655006749: 36413321723440003717 48112959837082048697
I won't score your answer on the following difficult test case which may be of interest for testing:
513231721363284898797712130584280850383: 40206835204840513073 12764787846358441471
Your score is the combined time to factor all the test cases above with a penalty of 10 minutes for each failed factorization (all rounded to the nearest second). Your code should work for other integers too, that is shouldn't just hardcode these answers.
I will stop your code after 10 minutes.
If two people get the same score then the first answer wins.
Your code can't use any builtin or library function that performs integer factorization. You can assume the input takes less than 256 bits. All input numbers will be composite.
How will I time?
I will literally run
time ./myprog on my Ubuntu system to do the timing so please also supply a complete program for me to run that includes any function you have defined.
A note for compiled languages
Compilation time must take no more than 1 minute on my machine.
Is it actually possible?
If you ignore the space constraints, then each one can be factored in less than 2 seconds on my computer using pure Python code + pypy.
So what is a non-trivial factoring algorithm?
Even faster is the Quadratic sieve. It looks like a serious challenge to squeeze that into 140 bytes.
- SEJPM, 10 minutes penalty for the last test case + 16 seconds in Haskell