[ create a new paste ] login | about

Link: http://codepad.org/wcKj76nW    [ raw code | output | fork ]

Python, pasted on Mar 18:
1
2
3
4
5
6
7
8
9
10
11
def factors(n):
    result = []

    for i in range(1, n + 1):
        if n % i == 0:
            result.append(i)

    return result

print factors(10)
print factors(100)


Output:
1
2
[1, 2, 5, 10]
[1, 2, 4, 5, 10, 20, 25, 50, 100]


Create a new paste based on this one


Comments: