This is a memo of the program code for finding the divisor.
div = []
num = int(input())
if num >= 2:
    for j in range(num):
        if num % (j + 1) == 0:
            div.append(j + 1)
    else:
        print(div)
The input value is divided by the loop processing of the for statement, and only when the remainder when divided is 0 is added to the array. Finally, the array is output.
Input value
28
Output value
[1, 2, 4, 7, 14, 28]
        Recommended Posts