diff options
| author | drbaggy <js5@sanger.ac.uk> | 2022-06-12 10:24:55 +0100 |
|---|---|---|
| committer | drbaggy <js5@sanger.ac.uk> | 2022-06-12 10:24:55 +0100 |
| commit | bfb2f77baa587efd8a99c991d81a5c1f24136209 (patch) | |
| tree | a9386e4210d84815cb694a11e456a7fbc056fcc2 /challenge-168/lubos-kolouch/python | |
| parent | 3c1dd872be61bf5ef7b1a974ab7b3ff09ff0225d (diff) | |
| parent | 79ce82da7c249f4af4572b7f951bca0adc45acbe (diff) | |
| download | perlweeklychallenge-club-bfb2f77baa587efd8a99c991d81a5c1f24136209.tar.gz perlweeklychallenge-club-bfb2f77baa587efd8a99c991d81a5c1f24136209.tar.bz2 perlweeklychallenge-club-bfb2f77baa587efd8a99c991d81a5c1f24136209.zip | |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-168/lubos-kolouch/python')
| -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 |
