Skip to content

Instantly share code, notes, and snippets.

@gaspart
Last active September 9, 2021 20:05
Show Gist options
  • Save gaspart/660e89c7569017e62f65d559f7e00d41 to your computer and use it in GitHub Desktop.
Save gaspart/660e89c7569017e62f65d559f7e00d41 to your computer and use it in GitHub Desktop.
divisori
# Python Program to find the factors of a number
# This function computes the factor of the argument passed
def print_factors(x):
old_i = 1
print("The factors of",x,"are:")
print(1)
for i in range(2, x + 1):
if x % i == 0:
for j in range(2, i + 1):
if i % j == 0:
if i != x:
if i != old_i:
print(i)
old_i = i
num = int(input("Please give me an integer number: "))
print_factors(num)
print(num)
@gaspart
Copy link
Author

gaspart commented Sep 9, 2021

v1
trovata sul web

v2
aggiunto l'imput utente
evitato la ripetizione dei fattori già presenti

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment