15)A school is preparing a large square floor for its annual function. The floor has N tiles arranged in a single row. The teacher wants to divide these tiles into equal-sized groups without leaving any tile unused. For example, if there are 12 tiles, the teacher can make:
1 group of 12 tiles
2 groups of 6 tiles
3 groups of 4 tiles
4 groups of 3 tiles
6 groups of 2 tiles
12 groups of 1 tile
Write a Python program that takes the number of tiles N and finds all possible group sizes that can divide the tiles equally.
no = 1029
div = 2
while div < no:
if no % div == 0:
print(div)
div+=1
Output:3
7
21
49
147
343
# first divisor
no = 1029
div = 2
while div < no:
if no % div == 0:
print(div)
break
div+=1
Output:3
# last divisor
no = 1029
div = 2
last_div = 0
while div < no:
if no % div == 0:
print(div)
last_div = div
div+=1
print("last div:" ,last_div)
Output:3
7
21
49
147
343
last div: 343
# two digit divisor
no = 1029
div = 10
while div < 100:
if no % div == 0:
print(div)
div+=1
Output:21
49
no = 1029
div = 10
while div < 100:
if no % div == 0:
print(div//10)
div+=1
Output:2
4
Top comments (0)