Find the Smallest Divisor of an Integer in python

Share on facebook
Share on twitter
Share on pinterest

In this Basic Python Program, we will have a look at how to “Find the smallest divisor of an integer” with the help of Python Programming Language.

Python Program To Find the Smallest Divisor of an integer

n=int(input("Enter an integer:"))

a=[]

for i in range(2,n+1):

    if(n%i==0):

        a.append(i)

a.sort()

print("Smallest divisor is:",a[0])

In the above program, we easily found the smallest divisor of an integer.

Subscribe to our Newsletter

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

Share this post with your friends

Share on facebook
Share on google
Share on twitter
Share on linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *