Python Forum
Juicy highly composite number needs factorization - 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: Juicy highly composite number needs factorization (/thread-18689.html)

Pages: 1 2


RE: Juicy highly composite number needs factorization - heiner55 - May-29-2019

My PC is too slow. How long does your PC run for 100 digits ?


RE: Juicy highly composite number needs factorization - kevolegend - May-29-2019

(May-29-2019, 02:24 AM)heiner55 Wrote: My PC is too slow. How long does your PC run for 100 digits ?

15 seconds roughly


RE: Juicy highly composite number needs factorization - heiner55 - May-30-2019

Intel I9 or AMD Razen ?


RE: Juicy highly composite number needs factorization - kevolegend - May-30-2019

(May-30-2019, 03:33 AM)heiner55 Wrote: Intel I9 or AMD Razen ?

Intel


RE: Juicy highly composite number needs factorization - heiner55 - May-31-2019

Thanks and have a good day.


RE: Juicy highly composite number needs factorization - heiner55 - Jun-03-2019

My PC was not slow, but with the below simple algorithm, my PC needs 1s.

#!/usr/bin/python3

def primeFactors(n):
    factors = []
    p = 2
    while n > 1:
        if n % p == 0:
            factors += [ p ]
            print(p, end=",")
            n = n // p
        else:
            p = p + 1
    print()
    return factors

def multiply(factors):
    n = 1
    for f in factors:
        n *= f
    return n

# main
n = 3226064841928059523397979569946338218262205752503893243027824368891777440698556243004554463193287418911567727801430320528268997104967216533294045386641450118600488493439275991430590233442080228938358171935320314414150553379009317199377287861726656707087781474818468157561232944906242003584398983171485589345483705115268063332800

print("number", n)

print("---")
factors = primeFactors(n)
print("---")

m = multiply(factors)
print("result", m)
print("---")

if n == m:
    print("OK")
else:
    print("ERROR")
#done
Output:
number 3226064841928059523397979569946338218262205752503893243027824368891777440698556243004554463193287418911567727801430320528268997104967216533294045386641450118600488493439275991430590233442080228938358171935320314414150553379009317199377287861726656707087781474818468157561232944906242003584398983171485589345483705115268063332800 --- 2,2,2,2,2,2,3,3,3,3,5,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773, --- result 3226064841928059523397979569946338218262205752503893243027824368891777440698556243004554463193287418911567727801430320528268997104967216533294045386641450118600488493439275991430590233442080228938358171935320314414150553379009317199377287861726656707087781474818468157561232944906242003584398983171485589345483705115268063332800 --- OK