I was wondering how this program knows if a number is prime or not. I understand that it checks for remainders to find even numbers to divide by but how does it know that a number has only 2 factors? I'm new to the concept of recursion so a explanation of the steps would be helpful thank you.
Code
def RecIsPrime(m):
"""Uses recursion to check if m is prime."""
def PrimeHelper(m, j):
"""Helper Function to iterate through all j less than m up to 1 to look for even divisors."""
if j == 1: # Assume 1 is a prime number even though it's debatable.
return True
else:
#do this task if both conditionals are true
#else break and return false.
return m % j != 0 and PrimeHelper(m, j - 1)
return PrimeHelper(m, m -1)
Source
https://github.com/hydrogeologist/LearningPython/blob/master/_recursion%20example%20in%20Python
Lines: 184 to 194