I tried to get ChatGPT to teach me a simple coding challenge today…

With a little help (from me), it got the following Python code:

```
# define the fibonacci_sequence function
def fibonacci_sequence(max):
fib = [0, 1]
while fib[-1] < max:
fib.append(fib[-1] + fib[-2])
return fib[:-1]
# call the fibonacci_sequence function to generate the sequence up to 10000
fib_seq = fibonacci_sequence(10000)
# calculate the sum of all numbers in the sequence
sum_fib = sum(fib_seq)
print("Fibonacci sequence up to 10000:", fib_seq)
print("Sum of all numbers in sequence:", sum_fib)
```

I asked ChatGPT why when I run the code I get a different number (17710):

Here, it fails to stop before 10000. But still thinks it gets 19683 (instead of the actual sum (28656).

I tried to get ChatGPT to show it’s work and do simple math on the sequence of fibonacci numbers under 10000:

I tried several times to get it to include the next number in the sequence (6765)

I keep trying, but it keeps refusing. And now it comes up with a different sum (12795):

It goes back to the Python script, but still gives the wrong number.

I tell it to forget about Python:

It still gets it wrong using plain but now, it’s just including 10946, instead of excluding it.

Finally, inexplicably, ChatGPT gets the right number.

But ChatGPT still can’t get it right, leaving out 4181 to get a total of 10945:

Finally, it acknowledges the correct answer:

I wonder if ChatGPT was explicitly programmed to give the wrong answer for common coding interview or homework questions — or if it’s a compulsive liar and can’t help itself.

Either way, be careful to not trust AI for answers, even for simple math.

## Leave a Reply