Package: primelibpy
Python Prime LibraryThis is the official documentation of the python prime library.Generate Specific types of Prime numbers between the given rangeGenerate Random Prime numberFactorization of the given numberInstallation!Use pip3 if you are using python version 3+ else follow the same steps as mentioned below:If you don’t have pip then follow the below procedure else go to step 2.For window UsersDownloadget-pipto a
folder on your computer.Put that file on DesktopOpen cmd and run the following commands:$ cd Desktop$ pythonget-pip.pyFor Mac UsersInstall python$ brew install pythonRun the following command:$ pythonget-pip.pyFor Linux UsersRun the following commands for python(version > 2.0):$ sudoapt-getinstallpython-pip$ sudo pacman-Spython2-pip$ sudo yum upgradepython-setuptools$ sudo yum installpython-pippython-wheel$ sudo dnf upgradepython-setuptools$ sudo dnf installpython-pippython-wheel$ sudo zypper installpython-pippython-setuptoolspython-wheelRun the following commands for python(version > 3.0):$ sudoapt-getinstallpython3-pip$ sudo pacman-Spython-pip$ sudo yum install python3python3-wheel$ sudo dnf install python3python3-wheel$ sudo zypper installpython3-pippython3-setuptoolspython3-wheelFor Raspberry UsersRun the following commands for python(version > 2.0):$ sudoapt-getinstallpython-pipRun the following commands for python(version > 2.0):$ sudoapt-getinstallpython3-pipImport gmpy2 fileThis package is required to install primelibpy libraryRun the following command$ pip installgmpy2==2.1.0a2Now, install the prime python library using the below command.Run the following command$ pip install primelibpyHow to use LibraryInside of your python IDE(Python file)from primelibpy import Prime as pNow, usingpall functions can be used in code
e.g.balancedNumberList = p.getBalancedPrime(2,100,2)Functions DescriptionPrime FunctionsIn all the prime numbers Start_Limit and End_Limit are the range of prime numbers the user wants to print inclusively.Balanced PrimeSyntex:getBalancedPrime(startLimit,endLimit,balancedMode)Return Type:listDescription:Balanced_Mode is how number which
decide a balanced limit for prime.Circular PrimeSyntex:getCircularPrime(startLimit,endLimit)Return Type:listCousin PrimeSyntex:getCousinPrime(startLimit,endLimit)Return Type:listDescription: Cousin prime are in pair so return list is have list
inside it e.g.[ [1,2], [2,3] ]Double Mersenne PrimeSyntex:getDoubleMersennePrime(startLimit,endLimit)Return Type:listFactorial PrimeSyntex:getFactorialPrime(startLimit,endLimit)Return Type:listGood PrimeSyntex:getGoodPrime(startLimit,endLimit)Return Type:listMersenne PrimeSyntex:getMersennePrime(startLimit,endLimit)Return Type:listPalindromic PrimeSyntex:getPalindromicPrime(startLimit,endLimit)Return Type:listPermutable PrimeSyntex:getPermutablePrime(startLimit,endLimit)Return Type:listPrimorial PrimeSyntex:getPrimorialPrime(startLimit,endLimit)Return Type:listFermat Pseudo PrimeSyntex:getFermatPseudoPrime(startLimit,endLimit,baseNumber)Return Type:listDescription:Base_number helps to generate a composite
the number and the second argument is the Total number of Pseudo primesPythagorean PrimeSyntex:getPythagoreanPrime(startLimit,endLimit)Return Type:listReversible PrimeSyntex:getReversiblePrime(startLimit,endLimit)Return Type:listSemi PrimeSyntex:getSemiPrime(startLimit,endLimit)Return Type:listSophie Germain PrimeSyntex:getSophieGermainPrime(startLimit,endLimit)Return Type:listTwin PrimeSyntex:getTwinPrime(startLimit,endLimit)Return Type:listDescription:Twin prime are in pair so return list is have list
inside it e.g.[ [1,2], [2,3] ]Wagstaff PrimeSyntex:getWagstaffPrime(startLimit,endLimit)Return Type:listWieferich PrimeSyntex:getWieferichPrime(startLimit,endLimit)Return Type:listWilson PrimeSyntex:getWilsonPrime(startLimit,endLimit)Return Type:listLeft Truncatable PrimeSyntex:getLeftTruncatablePrime(startLimit,endLimit)Return Type:listRight Truncatable PrimeSyntex:getRightTruncatablePrime(startLimit,endLimit)Return Type:listTruncatable PrimeSyntex:getTruncatablePrime(startLimit,endLimit)Return Type:listGaussian PrimeSyntex:checkGaussianPrime(realPart,imaginaryPart)Return Type:NoneNote:This will print whether the number is gaussian or notRandom Prime GenerationRandom Prime generation function has three arguments and it requires little knowledge of above all functions.The first argument is the type of prime number. Note thatname of primefollowed byPrime. The name of the prime type has to be in the capital.e.g.PrimorialPrimeThe second argument is the number of digits of random numbers.The third argument is only mandatory for balanced prime numbers.Syntex:getRandomPrime(primeType,totalDigits,mode=0)Return Type:integerExample:import Prime as prandomPrimorial =p.getRandomPrime("PrimorialPrime",3)FactorizationThis Section is related to Number factorization. Use Semi-Prime where it is indicated.Traditional Way for FactorizationSyntex:getFactorTraditional(semiPrimeNumber)Return Type:listNote: This function will work all kinds of numbers but I’ll suggest using Semi prime number because This function returns the Factor of input number except 1 and the number itself.Fermat Theorem for FactorizationSyntex:getFactorFermatTheorem(semiPrimeNumber)Return Type:tupleNote: This is only for composite numbers that have only two
prime factors except for the number itself e.g. 33 have two prime factors 3
and 11.Pollard Rho FactorizationSyntex:getFactorPollardRho(semiPrimeNumber)Return Type:integerNote:This will return any one factor of the given number
because this algorithm works on random numbers.General FactorizationSyntex:getAllFactors(compositeNumber)Return Type:listNote:This will return a list of all prime factors.LicenseMITFree Software, Hell Yeah!