Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """ This function returns a list of factors of a number """
- def print_factors(numbers):
- factors=[] # Setting an Empty List
- for number in range(1, numbers+1): # The range(1, number inclusive)
- if numbers % number == 0:
- factors.append(number)
- return factors
- print(print_factors(1)) # [1]
- print(print_factors(2)) # [1, 2]
- print(print_factors(10)) # [1, 2, 5, 10]
- print(print_factors(64)) #[1, 2, 4, 8, 16, 32, 64]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement