Guest User

Untitled

a guest
Apr 23rd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. my_list = [int(i) for i in input().split(' ')] # get items from input with spaces between
  2.  
  3. def find_integer_with_most_divisors(input_list):
  4. num, div = 0, 0 # tmp
  5.  
  6. for item in my_list: # iterate list
  7. div_count = 0
  8. for i in range(1, item + 1): # genrate numbers
  9. if item % i == 0: # check divisor
  10. div_count += 1
  11.  
  12. if div_count > div:
  13. num, div = item, div_count
  14.  
  15. # print(num, div)
  16. return num
  17.  
  18.  
  19. num = find_integer_with_most_divisors(my_list)
  20. print(num)
  21. # there might be better solutions. this one just pop in my mind.
Add Comment
Please, Sign In to add comment