gpt-4-1106-preview· openai
Suzhen/CodeChat
START OF PREVIOUS DISCUSSION END OF PREVIOUS DISCUSSION
- User
START OF PREVIOUS DISCUSSION END OF PREVIOUS DISCUSSION user: make a python script to print fibo numbers
- Assistant
Certainly! Below is a simple Python script that prints Fibonacci numbers. The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, usually starting with 0 and 1.
def fibo(n): """Prints Fibonacci sequence up to the nth Fibonacci number.""" a, b = 0, 1 # Initialize the first two Fibonacci numbers for _ in range(n): print(a, end=' ') a, b = b, a + b # Update the values to the next pair in the sequence num = int(input("How many Fibonacci numbers would you like to see? ")) fibo(num)Simply run this Python script in your environment, and it will prompt you to input the number of Fibonacci numbers you want to see. After you input the number, it will print the series up to that many Fibonacci numbers.