Skip to content

Joris Vergeer

Just some software engineer with some skills

Menu
  • Home
Menu

Multiplicative persistence

Posted on March 21, 2019October 17, 2019 by joris

After watching this @numberphile video I wanted to give it a try.

Then I came up with this piece if python code to try to find a possible 12 iteration sequence.

def factors(nr):
    i = 2
    factors = []
    while i <= nr:
        if (nr % i) == 0:
            factors.append(i)
            nr = nr / i
        else:
            i = i + 1
    return factors

def per_internal(iteration, number, doPrint = False):
    if doPrint:
        print '{} {} {}'.format(iteration, number, factors(number))

    if len(str(number)) == 1:
        return iteration
    
    digits = [int(i) for i in str(number)]

    result = 1
    for digit in digits:
        result *= digit

    return per_internal(iteration + 1, result, doPrint)

def per(number, doPrint = False):
    return per_internal(0, number, doPrint)

for x in range(0, 54):
    for y in range(0, 54):
        for z in range (0, 54):
            candidate = 2**x * 3**y * 7**z
            iterations = per(candidate, False)
            if iterations >= 10:
                per(candidate, True)

Result:

0 937638166841712 [2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 7, 7, 7, 7]
1 438939648 [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 7, 7]
2 4478976 [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3]
3 338688 [2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 7, 7]
4 27648 [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3]
5 2688 [2, 2, 2, 2, 2, 2, 2, 3, 7]
6 768 [2, 2, 2, 2, 2, 2, 2, 2, 3]
7 336 [2, 2, 2, 2, 3, 7]
8 54 [2, 3, 3, 3]
9 20 [2, 2, 5]
10 0 []

0 4996238671872 [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 7, 7, 7, 7, 7, 7]
1 438939648 [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 7, 7]
2 4478976 [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3]
3 338688 [2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 7, 7]
4 27648 [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3]
5 2688 [2, 2, 2, 2, 2, 2, 2, 3, 7]
6 768 [2, 2, 2, 2, 2, 2, 2, 2, 3]
7 336 [2, 2, 2, 2, 3, 7]
8 54 [2, 3, 3, 3]
9 20 [2, 2, 5]
10 0 []

Just put the prime factors after each other and you have your initial number.

You don’t have to search any further because 222222222222222222222222222222222222222222222222222222 is the first number that when each digit is multiplied is larger than the just found 937638166841712. You get 2^54 = 1,801439851×10¹⁶, which is larger.

Below this number, no numbers are found that create a 12 number sequence.

Sorry Matt,

11 is the max

Work

Currently working for and owner of RetailEntertainment B.V.
  • MKB-Muziek
  • Zorgscherm
  • Zorgstand
  • [C++/QT/OpenSSL/JWT] Minimalistic implementation to create a signed JTW token.
  • [C++/QT] QFuture delay method
  • [Vite] Copy vite build output to destination directory
  • [Python][Clang] Extract variabele value from a c++ file in python
  • [ASP.net Core] Body based routing with custom MatcherPolicy
  • March 2023 (2)
  • February 2023 (1)
  • January 2023 (1)
  • July 2020 (1)
  • November 2019 (1)
  • May 2019 (1)
  • March 2019 (2)
  • DevOps
  • Programming
  • Uncategorized
  • Web

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
© 2023 Joris Vergeer | Powered by Minimalist Blog WordPress Theme