0

I'm trying to find the total number of prime factors of a number using recursion. I've already implemented the code in scheme and it works fine. I am just curious what I'm doing wrong in python. It always returns none for some reason.

def findFactors(n,num,counter):
  if(n == 1):
      return counter
  elif (n % num == 0):
      findFactors(n / num, 2, counter + 1)
  else:
      findFactors(n,num+1,counter)

findFactors(4,2,0) should return 2 for example. Just another reminder that this works in scheme.

0 Answers0