All the divisors...
of a positive integer
The following is a 3.7 Python program. It has to be previously installed
#Divisors of a positive integer
x=int(input('Type a positive integer '))
for j in range(1,x+1):
if x//j==x/j:
print(j,end=',')
j=j+1
Example (1): For 3780
Type a positive integer 3780
1,2,3,4,5,6,7,9,10,12,14,15,18,20,21,27,28,30,35,36,42,45,54,60,63,70,84,90,105,108,126,135,140,180,189,210,252,270,315,378,420,540,630,756,945,1260,1890,3780,
Example (2): For 3781
Type a positive integer 3781
1,19,199,3781,
Example 3: For 3701
Type a positive integer 3701
1,3701,
No hay comentarios:
Publicar un comentario