Python Program To Find Factors Of A Number Using Recursion

Python Program To Find Factors Of A Number Using Recursion

Example

def factors(x,i):
    if(x >= i):
        if ((x%i)==0):
            print(i)
        factors(x,i+1)

n=18
# n = int(input("Enter Integer Value: "))
factors(n,1)

Output:

1
2
3
6
9
18

 

USEFUL POSTS:

  1. Python Program To Find Digits Sum Of Integer
  2. Python Program To Swap Two Numbers
  3. Python Program To Reverse A Number

Leave a comment