diff options
Diffstat (limited to 'challenge-168/lubos-kolouch/python/ch-2.py')
| -rw-r--r-- | challenge-168/lubos-kolouch/python/ch-2.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/challenge-168/lubos-kolouch/python/ch-2.py b/challenge-168/lubos-kolouch/python/ch-2.py new file mode 100644 index 0000000000..16094e836d --- /dev/null +++ b/challenge-168/lubos-kolouch/python/ch-2.py @@ -0,0 +1,19 @@ +from sympy import factorint, isprime + + +def home_prime(n): + + while not isprime(n): + factors = factorint(n) + + my_sum = "" + for (my_factor, repetition) in factors.items(): + my_sum += str(my_factor) * repetition + + n = int(my_sum) + + return n + + +assert home_prime(2) == 2 +assert home_prime(10) == 773 |
