diff --git a/nonrecfib.py b/nonrecfib.py new file mode 100644 index 0000000000000000000000000000000000000000..244fb825b2f9b64bef22791a3fc67961b8cd6ded --- /dev/null +++ b/nonrecfib.py @@ -0,0 +1,23 @@ +"""Document Comment.""" + + +def non_r_fib(num): + """Non Recursive Nth Fibonacci sequence.""" + tot, x_2, x_1 = 1, 0, 1 + for _ in range(num): + tot = x_1 + x_2 + x_2, x_1 = x_1, tot + + return tot + + +def main(): + """Test fib function.""" + print(non_r_fib(0)) + print(non_r_fib(44)) + print(non_r_fib(115)) + print(non_r_fib(1000)) + + +if __name__ == "__main__": + main()