Find the Divisors of a number

 

from math import sqrt

def div(n):

    div1=set()

    for i in range(1,int(sqrt(n))+1):

        if n%i==0:

            div1.add(i)

            div1.add(n//i)

    return sorted(list(div1))


n=int(input())

print("The divisors of ",n,"is",*div(n))


 

Comments

Popular posts from this blog

Trouble with the Number System

Residue Arithmetic

Perfect Peak of Array