title: Error when trying to run code with a higher integer value (n > 20)
body: <p>I'm a beginner programmer that's trying to write a program that requests an integer n within some defined limits and then computes certain mathematical functions and displays them in a formatted table.</p>
  <p>At the moment I have the limits set so that (0 &lt;= n &lt;= 10000) but this might be the issue for now.</p>
  <p>Here's my code:</p>
  <pre><code>
  #---------------------------Handling Exceptions------------------------------#
  # this deals with the user typing in letters or numbers outside of the limit
  # set
  def inputNumber():
      while True:
          try:
              userInput = int(input('Please enter an integer (0&lt;=n&lt;=10000): '))
              while (userInput &lt; 0) or (userInput &gt; 10000):
                  print('This value is outside of the limits! Please try again.')
                  userInput = int(input('Please enter an integer: '))
          except ValueError:
              print('You did not enter a valid integer! Please try again.')
              continue
          else:
              return userInput
  #---------------------------end Handling Exceptions--------------------------#
  
  #--------------------------Main Program Start--------------------------------#
  
  import numpy as np # importing the numpy library
  
  #inform the user what the program does
  print('\nThis program asks the user to enter an integer value n and computes')
  print(' sum(n), exp(n), n! and ln(n). It then displays the results in a table')
  
  # set the variable n to user defined function
  n = inputNumber()
  
  
  
  # putting titles for each output column
  title1, title2, title3, title4, title5 = 'n', 'sum(1..n)', 'exp(n)', 'n!', \
      'ln(n!)'
  
  # print in desired format
  print('\n{0:&gt;8}'.format(title1),
        '{0:&gt;10}'.format(title2),
        '{0:&gt;18}'.format(title3),
        '{0:&gt;20}'.format(title4),
        '{0:&gt;10}'.format(title5))
  
  # setting up operators for sum and factorial functions using numpy:
  def factorial(n): # function for factorial operator
     if n == 1:
         return n
     elif n == 0:
         return 1
     else:
         return n*factorial(n-1)
     
  def nsum(n): # this is the summing function over n
      if n == 0:
          return 0
      else:
          return int(n*(n + 1)/2) # had to convert string to integer format
      # reference: https://brilliant.org/wiki/sum-of-n-n2-or-n3/
  
      
  
  # evaluate and print in for loop
  for i in range(0, n+1):
      n_int = 0 + i
      sum_n = nsum(n_int)
      exp_n = np.exp(n_int)
      fact_n = factorial(n_int)
      logfact_n = np.log(factorial(n_int))
      
      print('{0:&gt;8d}'.format(n_int),
            '{0:&gt;10d}'.format(sum_n),
            '{0:&gt;18.3f}'.format(exp_n),
            '{0:&gt;20d}'.format(fact_n),
            '{0:&gt;10.3f}'.format(logfact_n))
  
  #--------------------------Main Program End----------------------------------#
  
  </code></pre>
  <p>The code runs fine and it is able to handle the exceptions but I get an AttributeError when I put n = 21.</p>
  <pre><code>AttributeError: 'int' object has no attribute 'log'
  
  
  The above exception was the direct cause of the following exception:
  
  Traceback (most recent call last):
  
    File &quot;C:\Users\pjjan\OneDrive\Documents\Python\forLoop3_19318421.py&quot;, line 79, in &lt;module&gt;
      logfact_n = np.log(factorial(n_int))
  
  TypeError: loop of ufunc does not support argument 0 of type int which has no callable log method
  </code></pre>
  <p>Here is the full output:</p>
  <pre><code>This program asks the user to enter an integer value n and computes
   sum(n), exp(n), n! and ln(n). It then displays the results in a table
  
  Please enter an integer (0&lt;=n&lt;=10000): 21
  
         n  sum(1..n)             exp(n)                   n!     ln(n!)
         0          0              1.000                     1      0.000
         1          1              2.718                     1      0.000
         2          3              7.389                     2      0.693
         3          6             20.086                     6      1.792
         4         10             54.598                    24      3.178
         5         15            148.413                   120      4.787
         6         21            403.429                   720      6.579
         7         28           1096.633                  5040      8.525
         8         36           2980.958                 40320     10.605
         9         45           8103.084                362880     12.802
        10         55          22026.466               3628800     15.104
        11         66          59874.142              39916800     17.502
        12         78         162754.791             479001600     19.987
        13         91         442413.392            6227020800     22.552
        14        105        1202604.284           87178291200     25.191
        15        120        3269017.372         1307674368000     27.899
        16        136        8886110.521        20922789888000     30.672
        17        153       24154952.754       355687428096000     33.505
        18        171       65659969.137      6402373705728000     36.395
        19        190      178482300.963    121645100408832000     39.340
        20        210      485165195.410   2432902008176640000     42.336
  AttributeError: 'int' object has no attribute 'log'
  
  
  The above exception was the direct cause of the following exception:
  
  Traceback (most recent call last):
  
    File &quot;C:\Users\pjjan\OneDrive\Documents\Python\forLoop3_19318421.py&quot;, line 79, in &lt;module&gt;
      logfact_n = np.log(factorial(n_int))
  
  TypeError: loop of ufunc does not support argument 0 of type int which has no callable log method
  </code></pre>
  <p>I don't know how to resolve the issue and I'm using Python 3.8 for anyone wondering. I hope someone can help! Thank you and sorry for any trivial mistakes I've made in the code. I'm very much a beginner.</p>