Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Jobthomas10 authored Dec 17, 2024
1 parent 34b6b51 commit 4fc8233
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Day-17/test.py
Original file line number Diff line number Diff line change
@@ -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))

0 comments on commit 4fc8233

Please sign in to comment.