title: Recursive function to know if a number is divisible by 3
body: <p>I need to create a recursive function which return me true if the input number it's divisible by 3. I know that it's more simple without recursion, but I need to create a function of this type.</p>
  
  <p>I've created a function, but i want to know if it's possible to create a better one, 'cause whit a big 'num', the function doesn't work. I think that I should use this fact: a natural number is divisible by 3 if the sum of its digits is divisible by 3.</p>
  
  <p>This is my code:</p>
  
  <pre><code>def divThree(num):
      if num==3:
          return true
      else:
          divThree(num-3)
  </code></pre>
  
  <p>EDIT: I created a better function, but i don't understand why doesn't return me true if the number is divisible by three. Instead, if it isn't, goes on maximum recursion error.</p>
  
  <pre><code>def recursiveThree(num):
    if num==3 or num==6 or num==9:
      return true
    else:
      sum=0
      sNum=str(num)
      for i in range(0,len(sNum)):
        sum=sum+int(sNum[i])
      recursiveThree(sum)
  </code></pre>