Created
February 2, 2017 19:43
-
-
Save AliSajid/1116952ca0206350e24d13ed221dce37 to your computer and use it in GitHub Desktop.
This file contains 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
# Define the factorize function | |
def factorize(number): | |
factors = [i, int(n/i) for i in range(1, 1+number/2) if number % i == 0] | |
return set(sorted(factors)) | |
# Define the printing function | |
def print_factors(factor_array): | |
for n in factor_array: | |
print("{} is a factor".format(n)) | |
# Ask for the number | |
n = int(input("Please enter the number you need the factors of: ")) | |
print("Factorizing the integer...") | |
print_factors(factorize(n)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment