Python Forum
How do I code this equation in python (factor ceiling(2^127-1)) - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How do I code this equation in python (factor ceiling(2^127-1)) (/thread-9658.html)



How do I code this equation in python (factor ceiling(2^127-1)) - Pleiades - Apr-21-2018

I want to factor this equation and I was doing so well on wolfram but now they want me to pay to see answers. Bummer!

How do I write the code for this one? Any help is Awesome!

Factor
ceiling(2^127-1)-1

[Image: ceiling2127-1-1.png]



http://www.wolframalpha.com/widgets/view.jsp?id=5c9daaf5cc8da89d8fd910ddee57d91e


RE: How do I code this equation in python (factor ceiling(2^127-1)) - Skaperen - Apr-22-2018

how do you write ceiling(2^127-1)-1? i can understand (2^127-1)-1 but i don't understand ceiling() in the context of factoring. ceiling(170141183460469231731687303715884105727)-1?

are you trying to compile a list of Mersenne Primes?


RE: How do I code this equation in python (factor ceiling(2^127-1)) - Gribouillis - Apr-22-2018

cypari gives some result:
>>> import cypari
>>> cypari.pari('factor({})'.format(2**127-2))
[2, 1; 3, 3; 7, 2; 19, 1; 43, 1; 73, 1; 127, 1; 337, 1; 5419, 1; 92737, 1; 649657, 1; 77158673929, 1]



RE: How do I code this equation in python (factor ceiling(2^127-1)) - Pleiades - Apr-22-2018

(Apr-22-2018, 05:15 AM)Skaperen Wrote: how do you write ceiling(2^127-1)-1? i can understand (2^127-1)-1 but i don't understand ceiling() in the context of factoring. ceiling(170141183460469231731687303715884105727)-1?

are you trying to compile a list of Mersenne Primes?

Skaperen I'm trying to predict Mersenne Primes and I know that is nuts, but I have spare time so what the heck lol.

(Apr-22-2018, 05:57 AM)Gribouillis Wrote: cypari gives some result:
 >>> import cypari >>> cypari.pari('factor({})'.format(2**127-2)) [2, 1; 3, 3; 7, 2; 19, 1; 43, 1; 73, 1; 127, 1; 337, 1; 5419, 1; 92737, 1; 649657, 1; 77158673929, 1] 
Hi,
I'm now trying to do this calculation at the interpreter and I get this error. Maybe in 10 years I'll see the answer to this one. No bad on you, but this is very complex.
My computer is running the latest version of mpmath 1.0.0

ERROR_
3**1279 % 19.1
OverflowError: int too large to convert to float


RE: How do I code this equation in python (factor ceiling(2^127-1)) - Gribouillis - Apr-22-2018

(Apr-22-2018, 07:39 AM)Pleiades Wrote: OverflowError: int too large to convert to float
You need the floating type mpmath.mpf. The following computation may be correct (read the doc!)
>>> import mpmath as mp
>>> mp.mp.dps = 1000
>>> mp.mp.prec
3325
>>> x = mp.mpf(3**1279)
>>> x
mpf('17301541007910038054176056432452867095149043770336183739760994896914962855011729112692135469308113595623662446442598795834444897233706143344824357701420610156423345105638078275879693218333055393875886226458620734496461814517152992352402982745998689203987491576943864064210130929012975963553401138869026447532834194444684876122440822192338479455455335994013248316240321358466758500551665434276274478532775337486153362645579799959393898179890245190220628605618273528084601403702463029225950540686613177600948606835157545386013111476205803857649578582946755008105822347197520438156375214337925994262260644194653867.0')
>>> x % mp.mpf('19.1')
mpf('10.19999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999986211221154848220654005392902057139770156790286166144188800371401237452170538589543598035521683264914310586337686699894347939024860146540757548385574874504630831265632890197664535441563639513497048756683543708442778829491602757769872393215591581152938167421054163471394836743703044131001404204016205461841021455948652709053963994607698563023642172696945794949806477041895118333497516253529717948650209753919929653496184540071834200082524982267781226809556415809041082332587896492941756602172886446388115227194726605314781134096334203545572724145359345153758473917409997845778716764066425820393664286016039105526')
You can do it without mpmath, using only integers:
>>> (3**1279*10) % 191
102



RE: How do I code this equation in python (factor ceiling(2^127-1)) - Skaperen - Apr-23-2018

what is it you are trying to accomplish in your spare time ... factorize all non-prime Mersenne numbers? or factorize the numbers one less than Mersenne numbers? or find which are prime? are you using a gauntlet of multi-core cloud instances?