Last active
April 15, 2018 21:17
-
-
Save r6m/93ec72226b928061f71f3fbe1e96a2d0 to your computer and use it in GitHub Desktop.
find integer with most divisors
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
my_list = [int(i) for i in input().split(' ')] # get items from input with spaces between | |
def find_integer_with_most_divisors(input_list): | |
num, div = 0, 0 # tmp | |
for item in my_list: # iterate list | |
div_count = 0 | |
for i in range(1, item + 1): # genrate numbers | |
if item % i == 0: # check divisor | |
div_count += 1 | |
if div_count > div: | |
num, div = item, div_count | |
# print(num, div) | |
return num | |
num = find_integer_with_most_divisors(my_list) | |
print(num) | |
# there might be better solutions. this one just pop in my mind. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment