Python Forum
Juicy highly composite number needs factorization
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Juicy highly composite number needs factorization
#11
My PC is too slow. How long does your PC run for 100 digits ?
Reply
#12
(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
Reply
#13
Intel I9 or AMD Razen ?
Reply
#14
(May-30-2019, 03:33 AM)heiner55 Wrote: Intel I9 or AMD Razen ?

Intel
Reply
#15
Thanks and have a good day.
Reply
#16
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python script to summarize excel tables, then output a composite table? i'm a total n surfer349 1 2,354 Feb-05-2021, 04:37 PM
Last Post: nilamo
  random fiber distribution for composite analysis pvdivakarraju 1 1,659 Jan-21-2021, 07:42 PM
Last Post: Larz60+
  How do I stop this fast factorization program from printing beyond the 3rd output? Pleiades 6 3,866 Dec-07-2019, 08:43 PM
Last Post: Pleiades

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020