-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path8.py
36 lines (26 loc) · 806 Bytes
/
8.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Write a Python program that takes a number as input from the user and prints the divisors of that number
# as well as how many divisors the number has.
# Sample Input 1: Sample Output 1:
# 6 1
# 2
# 3
# 6
# Total 4 divisors.
count = 0
number = int(input("Enter a number: "))
for i in range(1, number+1):
if number % i == 0:
val = i
count +=1
print(i)
print("Total " + str(count) + " divisor(s).")
#before
x = input()
xx = int(x)
count = 0
for i in range(1, xx+1):
d = xx % i
if d == 0:
count += 1
print(i)
print(f"Total {count} divisors.")