Skip to content

Instantly share code, notes, and snippets.

@gegen07
Created April 18, 2019 13:10
Show Gist options
  • Save gegen07/e62ce58b8820d02d11684274434be1f5 to your computer and use it in GitHub Desktop.
Save gegen07/e62ce58b8820d02d11684274434be1f5 to your computer and use it in GitHub Desktop.
Get all div of a number
fator = 2
n = int(input())
vetor = []
aux = []
while n > 1:
while n % fator == 0:
n /= fator
if len(vetor) > 0:
for i in vetor:
if (fator*i) not in vetor:
aux.append(fator*i)
vetor.extend(aux)
aux = []
else:
vetor.append(fator)
fator += 1
vetor.sort()
print(vetor)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment