Python and the equivalent of perl's bigint package??? | Sololearn: Learn to code for FREE!
+ 2

# Python and the equivalent of perl's bigint package???

Is there a python module that's is equivalent to perl's bigint package? i have greatly inproved the preformance of my perfect number program, "perfetNumberGen 5.py". this version will find the first seven perect numbers, the old vers "perfectNumber 3.py" would only find the first four perfect numbers. I have a perl version of "perfetNumberGen 5" that uses perl's bigint package and finds the first eight perfect numbers in 24 seconds of CPU time on my old G4 powerbook running MacOSX 10.4.11. The python version dies of a malloc error when checking if the 2**29 - 1 is merenne number is prime. It is not and the 31th merenne number is prime and generates the 8th perfect number. I run out of time on SoloLearn's code playground. Is there an almost infinite precision integer arithmetic module for python Note: the nth merenne number is mn(n) = (2**n)-1. If mn(n) is prime then pn(n) = mn(n)*2**(n-1) is a perfect number,

9th Jul 2018, 10:40 PM
Rick Shiffman
2 ответов
+ 2
I just experimented with Python 2.7 instead of the 1.8 my old Mac has. I used a IDLE to test it out interactively. It looks like most of the problems I complained about last night were due to my old version of Python matter-of-fact with IDLE i found that the number object have unlimited precision. see IDLE session below Python 2.7.10 (default, Oct 6 2017, 22:29:07) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin .............. Here is the IDLE code. import sys import math """Most likely a perfect""" n = 127 mn = (2**n)-1 pn = mn * 2**(n-1) print(pn) """All known Perfect numbers end in 6 or 8"""
11th Jul 2018, 7:06 AM
Rick Shiffman
+ 2
here is the output from IDLE And is most likely a perfect number. (2**n - 1)* 2**( n - 1) for n = 127 the perfect number candidate is: import sys import math """Most likely a perfect""" n = 127 mn = (2**n)-1 pn = mn * 2**(n-1) print(pn) """ Its 79 digits long. All known Perfect numbers end in 6 or 8. it's a very large number"""
11th Jul 2018, 8:19 AM
Rick Shiffman
Актуальное сегодня
HELP ME