From 46ea32bd03151070ca9a5853da995a378496c781 Mon Sep 17 00:00:00 2001 From: Tharakadhanushka Date: Thu, 17 Oct 2019 06:10:02 +0530 Subject: [PATCH] added factors --- factors.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 factors.py diff --git a/factors.py b/factors.py new file mode 100644 index 0000000..708b384 --- /dev/null +++ b/factors.py @@ -0,0 +1,18 @@ +# Python Program to find the factors of a number + +# define a function +def print_factors(x): + # This function takes a number and prints the factors + + print("The factors of",x,"are:") + for i in range(1, x + 1): + if x % i == 0: + print(i) + +# change this value for a different result. +num = 320 + +# uncomment the following line to take input from the user +#num = int(input("Enter a number: ")) + +print_factors(num) \ No newline at end of file