You will write a function that breaks a number into primes, then use it to test for primes and to find numbers in which no prime repeats.
The idea. Divide by while you can, then by , then by (which never divides, since the s are gone), and so on, until is left.
Your tasks.
prime_factors, return the list of prime factors of n, smallest first, with repeats. For it is [2, 2, 3].is_prime, return True when n is a prime: it has exactly one prime factor.no_repeats with the numbers of numbers in which no prime appears twice.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…