Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

factors of a number

def factors(num):
    """Get factors for given integer."""
    result = set()
    for i in range(1, int(num ** 0.5) + 1):
        if num % i == 0:
            result.update({i, num // i})
    return result
 
PREVIOUS NEXT
Tagged: #factors #number
ADD COMMENT
Topic
Name
5+5 =