Finding divisors
Write code · Basic · §2.2 Divisors and multiples
Complete the function solution, which returns a list of the divisors of the positive integer n in ascending order.
Function
solution(n)
Constraints
nis an integer from 1 to 1,000,000,000.
Examples
| n | result |
|---|---|
12 | [1, 2, 3, 4, 6, 12] |
7 | [1, 7] |
Starter code
def solution(n):
answer = []
return answerSolve this problem in your browser
Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.