diff --git a/main.py b/main.py index 3825247..27dd26e 100644 --- a/main.py +++ b/main.py @@ -1,12 +1,23 @@ def factorial(n): """Calculates the factorial of a non-negative integer.""" - # TODO: Implement the logic - pass + result = 1 + for i in range(1, n + 1): # multiply numbers from 1 up to n + result *= i + return result + def fibonacci(n): """Returns the nth number in the Fibonacci sequence.""" - # TODO: Implement the logic - return None + 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 + def fizzbuzz(n): """ @@ -15,5 +26,14 @@ def fizzbuzz(n): - Multiples of 5 are "Buzz" - Multiples of both 3 and 5 are "FizzBuzz" """ - # TODO: Implement the logic - return [] \ No newline at end of file + result = [] + for i in range(1, n + 1): + if i % 3 == 0 and i % 5 == 0: + result.append("FizzBuzz") + elif i % 3 == 0: + result.append("Fizz") + elif i % 5 == 0: + result.append("Buzz") + else: + result.append(i) + return result