From 4fc8233213b1fb1c941543f7fe75c986e0a1cd3f Mon Sep 17 00:00:00 2001 From: Jobthomas10 Date: Tue, 17 Dec 2024 10:49:25 +0530 Subject: [PATCH] Add files via upload --- Day-17/test.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Day-17/test.py diff --git a/Day-17/test.py b/Day-17/test.py new file mode 100644 index 0000000..2291311 --- /dev/null +++ b/Day-17/test.py @@ -0,0 +1,34 @@ +def factorial(n): + if n==0 or n==1: + return 1 + return n* factorial(n-1) +number=3 +print(f"factorial of {number}:{factorial(number)}") + + + +def fibonacci(n): + if n==0: + return 0 + if n==1: + return 1 + return fibonacci(n-1)+fibonacci(n-2) +number=6 +print(f"fibinocci of {number}:{fibonacci(number)}") + + +def sum_of_digits(n): + if n==0: + return 0 + return n%10+ sum_of_digits(n//10) +number=1234 +print(sum_of_digits(number)) + + +def factorial_iterative(n): + result = 1 + for i in range(1, n + 1): + result *= i + return result +number=5 +print(factorial_iterative(number))