title: Recursion: Palindromic Primes
body: <p>I need to create a recursive function to find all palindromic primes between two numbers. The trick is not to use any for of loop or iteration at all. As a beginner to programming I struggle with recursion and have managed to write the program with loops as:</p>
  
  <pre><code>def palindrome(startpoint,endpoint):
  
      print("The palindromic numbers are:\n")
      num = ''
      inverted = ''
      for i in range(startpoint+1,endpoint):
          num = str(i)
  
          for j in range(len(num)-1, -1, -1):
              inverted += str(num[j])
  
          if (num == inverted):
              print(num)
          num = ''
          inverted = ''
  
  
  def main():
  
      startpoint = eval(input("Enter the starting point N:\n"))
      endpoint = eval(input("Enter the ending point M::\n"))
      palindrome(startpoint,endpoint)
  
  main()    
  </code></pre>
  
  <p>I've been trying to write this program recursively but with no luck.</p>
  
  <p>Do I first treat the numbers as strings and check if they are palindromes like this?</p>
  
  <pre><code>def palindrome (str):
     if str == "":
        return str
     else:
        return palindrome (str[1:]) + str[0]
  </code></pre>
  
  <p>Then check for prime numbers like this:</p>
  
  <pre><code>def prime(n):
  
  if n%2 == 0:
      return False
  else: 
      return True
  </code></pre>
  
  <p>I'm still trying to work this stuff out, any help would be appreciated:)</p>