Generating the First 10 Fibonacci Numbers

Prompt

write first 10 Fibonacci's numbers
Python

Result

def fibonacci(n):
    """
    Generate the first n Fibonacci numbers.

    Parameters:
    n (int): The number of Fibonacci numbers to generate.

    Returns:
    list: A list containing the first n Fibonacci numbers.
    """
    fib_numbers = [0, 1]  # Initialize the list with the first two Fibonacci numbers

    # Generate the remaining Fibonacci numbers
    for i in range(2, n):
        fib_numbers.append(fib_numbers[i-1] + fib_numbers[i-2])

    return fib_numbers[:n]  # Return only the first n Fibonacci numbers


# Generate the first 10 Fibonacci numbers
fibonacci_numbers = fibonacci(10)

# Print the Fibonacci numbers in markdown format
print("| Fibonacci Numbers |")
print("|-------------------|")
for number in fibonacci_numbers:
    print(f"| {number} |")
Python

Output:

Fibonacci Numbers
0
1
1
2
3
5
8
13
21
34