-
-
Save akashmdiu/dd447ba53f322bf46ef12b5d73e30d48 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Title: Calculate Fibonacci Sequence | |
# Description: A Python function to calculate the Fibonacci sequence up to a specified number of terms. | |
def fibonacci(n): | |
sequence = [0, 1] | |
while len(sequence) < n: | |
next_number = sequence[-1] + sequence[-2] | |
sequence.append(next_number) | |
return sequence | |
# Example usage | |
fib_sequence = fibonacci(10) | |
print(fib_sequence) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment