Sunday, 4 December 2016

Factors/Divisors of number

#Divisors of number/Factors of number
#Divisor/factor of an integer n, is an integer that can be multiplied by some other integer to produce n. 

#accepting number from user
n=int(input('enter no:'))

#each number is divisible by 1 as well as by itself.
print("1 &", n , ' are factor of ' , n)

#to display other divisors/factors
for i in range(2,n):
    if(n%i==0):
        print(i , ' , ' ,end='')
print(' are factors of ', n)

OUTPUT:



No comments:

Post a Comment