From fbe67d4a7029265af7d2e0a7ff6bd642bc748105 Mon Sep 17 00:00:00 2001 From: Lubos Kolouch Date: Sat, 11 Jun 2022 19:03:46 +0200 Subject: feat(challenge-168/lubos-kolouch/p[erl,ython]/ch-2.p[ly]): Challenge 168 Task 2 LK Perl Python --- challenge-168/lubos-kolouch/python/ch-2.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 challenge-168/lubos-kolouch/python/ch-2.py (limited to 'challenge-168/lubos-kolouch/python') 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 -- cgit