title: How to print sum of numbers to n recursively?
body: <p>I have written a function to print of sum of numbers to n.</p>
  <pre><code>def sumOfDigits(n):
      sum = 0
      if n &lt; 0:
          print(&quot;Enter a positive number&quot;)
      else:
          while (n &gt; 0):
              sum = sum + n
              n -= 1
          return sum
  
  print(sumOfDigits(4))
  </code></pre>
  <p>Which prints the result fine but now i am trying to do it recursively.</p>
  <pre><code>def sumOfDigits(n):
      assert n &gt;= 0 and int(n) == n, 'The number must be positive integer only'
      if n == 0:
          return 0
      else:
          while n &gt; 0:
              return sumOfDigits(n) + sumOfDigits(n-1)
  
  print(sumOfDigits(3))
  </code></pre>
  <p>But i am getting the following error :-</p>
  <pre><code>assert n&gt;= 0 and int(n) == n, 'The number must be positive integer only'
     RecursionError: maximum recursion depth exceeded in comparison
  </code></pre>
  <p>Any help will be appreciated. Thank you.</p>