尝试通过python中的递归来解决Project Euler(问题3)中的最大素数问题

我一直在尝试解决python中ProjectEuler中的问题3。我尝试使用递归来获取因素的因素。但是由于某种原因,我继续遇到递归限制达到错误。谁能帮我解决为什么会这样?

def getPrimeFactors(y):
  AllFactors = [[x, int(y/x)] for x in range(1, (int(math.sqrt(y)+1))) if y%x==0]
  Flattened_AF = [j for i in AllFactors for j in i]
  print(AllFactors)
  print(Flattened_AF)

  if len(Flattened_AF)==2:
    print(Flattened_AF)
    return Flattened_AF
  else:
    PrimeFactors = [x for x in Flattened_AF if len(getPrimeFactors(x))==2]
    print (f'else{PrimeFactors}')
    print(max(PrimeFactors)

getPrimeFactors(4)

This is the problem as quoted in the website.