Last active
September 9, 2021 20:05
-
-
Save gaspart/660e89c7569017e62f65d559f7e00d41 to your computer and use it in GitHub Desktop.
divisori
This file contains 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
# 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
v1
trovata sul web
v2
aggiunto l'imput utente
evitato la ripetizione dei fattori già presenti