1

I have a problem getting a cubic root of an approximately 128-bit integer in Python2. The following assertion gives me an error:

assert 188098593525197704876445094491719024115 == ((188098593525197704876445094491719024115) ** 3) ** (1.0/3)

I tried Decimal class with a precision set to 600 but it still gives me a value off approximately for 6-12 digits.

How can I get this working (preferably without custom libraries)?

ddnomad
  • 373
  • 3
  • 15
  • 1
    I am just curious to know, where you could apply these long integers computation? Thanks! – manvi77 Apr 01 '17 at 05:57
  • 1
    @manvi77 I'm trying to make a proof-of-work for cracking textbook RSA with public exponent equal to 3 and a plain text that is much smaller then the encryption modulus. Basically, all boils down to getting a cubic root of a huge integer. And while mathematically it works I can't get it working because of precision issues. – ddnomad Apr 01 '17 at 06:00
  • There are some answers here: http://stackoverflow.com/questions/356090/how-to-compute-the-nth-root-of-a-very-big-integer – xyres Apr 01 '17 at 06:19
  • @xyres thank you very much! the accepted answer actually solves my problem. Though I need quite a bit of time to get a grasp on what it's actually doing. – ddnomad Apr 01 '17 at 06:28
  • NthRoot is pretty simple. If you can read Pascal, take a look at my implementation: https://github.com/rvelthuis/BigNumbers/blob/master/Source/Velthuis.BigIntegers.pas. Look for `NthRoot`. In your case, `Nth` would be 3 (third). – Rudy Velthuis Apr 02 '17 at 15:00

0 Answers0