Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2020
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. def find_divisors(num):
  2.     simple = [2,3,5,7]
  3.     working = [num]
  4.     new = []
  5.     final = [1,num]
  6.     count = 0
  7.     while True:
  8.         added = False
  9.         count += 1
  10.         for x in working:
  11.             count += 1
  12.             simple_div = [z for z in simple if x % z == 0]
  13.             count += 5
  14.             for y in simple_div:
  15.                 count += 1
  16.                 n = x / y
  17.                 new.append(n)
  18.         for n in set(new):
  19.             count += 1
  20.             if n not in final:
  21.                 final.append(int(n))
  22.                 added = True
  23.         working = list(map(int,set(new)))
  24.         new = []
  25.         if added is False:
  26.             return list(sorted(final)),count
  27.  
  28. print(find_divisors(250))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement