From 372941601f535e30b7c877b6addf6810c9f592b8 Mon Sep 17 00:00:00 2001 From: Kumaran Date: Wed, 6 Oct 2021 20:13:16 +0530 Subject: [PATCH] recursive algorithm added --- Algorithms/Python/Fibonacci.py | 16 ++++++++++++++++ Algorithms/Python/sum_cubes.py | 13 +++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 Algorithms/Python/Fibonacci.py create mode 100644 Algorithms/Python/sum_cubes.py diff --git a/Algorithms/Python/Fibonacci.py b/Algorithms/Python/Fibonacci.py new file mode 100644 index 0000000..ddeef2e --- /dev/null +++ b/Algorithms/Python/Fibonacci.py @@ -0,0 +1,16 @@ +def Fibonacci(n): + if n <= 1: + return n + else: + return (Fibonacci(n-1) + Fibonacci(n-2)) + + + + + +while(1): + N = int(input("enter an integer: ")) + if N == -1: + break + + print( Fibonacci(N)) diff --git a/Algorithms/Python/sum_cubes.py b/Algorithms/Python/sum_cubes.py new file mode 100644 index 0000000..aa696fa --- /dev/null +++ b/Algorithms/Python/sum_cubes.py @@ -0,0 +1,13 @@ +def sumcube(no): + if(no == 1): + return 1 + else: + return(no * no * no + sumcube(no - 1)) + + +while(1): + n = int(input("enter the number : ")) + if(n == -1): + break + print(sumcube(n)) +