Skip to content
TheChatArchiveThe Chat Archive
gpt-4-1106-preview· openaiHugging Face Suzhen/CodeChat

START OF PREVIOUS DISCUSSION END OF PREVIOUS DISCUSSION

  1. User

    START OF PREVIOUS DISCUSSION END OF PREVIOUS DISCUSSION user: make a pythons cript to print fibonnanci numbers

  2. Assistant

    Here's a simple Python script that prints Fibonacci numbers. A Fibonacci number is either number 0 or 1, or the sum of the two previous numbers.

    def fibonacci(n):
        a, b = 0, 1
        for _ in range(n):
            print(a, end=' ')
            a, b = b, a + b
    
    print("How many Fibonacci numbers to generate?")
    num = int(input())
    
    fibonacci(num)
    

    When you run this script, it will ask for the number of Fibonacci numbers you would like to generate, and then it will output them in a sequence, all on the same line. If you would prefer to have them printed on separate lines, you can replace print(a, end=' ') with print(a) instead.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.