GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Python/maths/fibonacci_sequence_recursion.py at master · SharathKumarGithub/Python Expand file tree/ Copy pathfibonacci_sequence_recursion.pyMore file actions 22 lines (16 loc) · 571 Bytes / Copy pathfibonacci_sequence_recursion.pyFile metadata and controls22 lines (16 loc) · 571 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 # Fibonacci Sequence Using Recursion def recur_fibo(n): """ >>> [recur_fibo(i) for i in range(12)] [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] """ return n if n <= 1 else recur_fibo(n - 1) + recur_fibo(n - 2) def main(): limit = int(input("How many terms to include in fibonacci series: ")) if limit > 0: print(f"The first {limit} terms of the fibonacci series are as follows:") print([recur_fibo(n) for n in range(limit)]) else: print("Please enter a positive integer: ") if __name__ == "__main__": main() |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |