Created
August 30, 2021 19:51
-
-
Save pamelafox/591315b87e520ad0609ed0c64b65a59a to your computer and use it in GitHub Desktop.
Prime Factors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_prime(n): | |
"""Return True iff N is prime. | |
>>> is_prime(1) | |
False | |
>>> is_prime(2) | |
True | |
>>> is_prime(8) | |
False | |
>>> is_prime(21) | |
False | |
>>> is_prime(23) | |
True | |
""" | |
return n > 1 and smallest_factor(n) == n | |
def smallest_factor(n): | |
"""Returns the smallest value k>1 that evenly divides N.""" | |
pass | |
def print_factors(n): | |
"""Print the prime factors of N. | |
>>> print_factors(180) | |
2 | |
2 | |
3 | |
3 | |
5 | |
""" | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment