Seriously icon indicating copy to clipboard operation
Seriously copied to clipboard

Factoring fails for large inputs

Open Mego opened this issue 8 years ago • 1 comments

Code: :1965593254291461501637330902918203684832716283082y (w produces similar results)

Error:

Traceback (most recent call last):
  File "/opt/actually/seriously/seriously.py", line 231, in eval
    self.fn_table.get(ord_cp437(c), lambda x: x)(self)
  File "/opt/actually/seriously/SeriouslyCommands.py", line 1349, in <lambda>
    0x79:lambda x:x.push(factor(x.pop())),
  File "/opt/actually/seriously/SeriouslyCommands.py", line 579, in factor
    return [a for a,b in full_factor(n)]
  File "/opt/actually/seriously/SeriouslyCommands.py", line 560, in full_factor
    init_primes_up_to(int(rmath.sqrt(n))+1)
  File "/opt/actually/seriously/SeriouslyCommands.py", line 259, in init_primes_up_to
    temp=[1]*(n-max_tested)
OverflowError: cannot fit 'int' into an index-sized integer

The factoring algorithm needs to be more memory-efficient. Perhaps there should be a threshold value set for switching over to a slower-but-memory-efficient algorithm instead of the current somewhat-fast-but-memory-intensive approach.

@kckennylau Any thoughts?

Mego avatar Jul 07 '17 11:07 Mego

For big numbers: https://en.wikipedia.org/wiki/Pollard%27s_rho_algorithm For big numbers: https://en.wikipedia.org/wiki/General_number_field_sieve

SIGSTACKFAULT avatar Nov 12 '17 22:11 SIGSTACKFAULT