Python program for fibonacci sequence using a recursive function A Fibonacci sequence is the integer sequence of 0, 1, 1, 2, 3, 5, 8.....

The first two terms are 0 and 1. All the other terms are obtained by adding the preceding two terms.

Here is my code:

def recur_fibonacci(n):
   if n &lt;= 1:
       return n
   else:
       return(recur_fibonacci(n - 1) + recur_fibonacci(n - 2))

nterms = int(input("How many terms? "))

if nterms &lt;= 0:
   print("Please enter a positive integer!")
else:
   print("Fibonacci sequence:")
   for i in range(nterms):
       print(recur_fibonacci(i))


So I would like to know whether I could make this program shorter and more efficient.

Any help would be highly appreciated.
Since other answers have focused on the code quality itself, I'll focus on performance.

Recursive Fibonacci by itself is \$O(2^n)\$ time.

Memoized fibonacci is linear time (check out functools.lru_cache for a quick and easy one). This is because fibonacci only sees a linear number of inputs, but each one gets seen many times, so caching old input/output pairs helps a lot.

Golden-ratio based solutions are approximately \$O(\log(n))\$, using \$\text{Fib}(n) = \frac{\phi^n - (1 - \phi)^n}{\sqrt 5}\$, where \$\phi\$ is the golden number. Note that without arbitrary precision numbers, this approach becomes inaccurate at large values of n. With increased precision, note that the cost of a multiplication increases as well, making the whole process a bit slower than log(n).