From 732ae882ec2ca5d928fc131437c48d8291579746 Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Tue, 4 Mar 2025 15:53:58 +0300 Subject: Revert "feat: Add Python implementation of Fibonacci number calculation". This reverts commit 280c5e97d21501c03f672ed3576ae3eddfc76420. --- scripts/fibonacci.py | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 scripts/fibonacci.py (limited to 'scripts/fibonacci.py') diff --git a/scripts/fibonacci.py b/scripts/fibonacci.py deleted file mode 100644 index 0ee6afe..0000000 --- a/scripts/fibonacci.py +++ /dev/null @@ -1,42 +0,0 @@ -""" -This module provides a function to calculate the nth Fibonacci number using an iterative approach. -""" - -def fibonacci(n: int) -> int: - """ - Calculate the nth Fibonacci number. - - The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones. - Typically starting with 0 and 1. - - Args: - n (int): The position in the Fibonacci sequence to calculate. Must be a non-negative integer. - - Returns: - int: The nth Fibonacci number. - - Raises: - ValueError: If n is not a non-negative integer. - """ - if not isinstance(n, int): - raise ValueError("Input must be an integer.") - if n < 0: - raise ValueError("Input must be a non-negative integer.") - if n == 0: - return 0 - elif n == 1: - return 1 - - a, b = 0, 1 - for _ in range(2, n + 1): - a, b = b, a + b - return b - -if __name__ == "__main__": - # Example usage: - try: - position = 10 - result = fibonacci(position) - print(f"The {position}th Fibonacci number is: {result}") - except ValueError as e: - print(f"Error: {e}") -- cgit 1.4.1