ChatGPT calculations are wrong

Hey Ruby, now that I am a coding expert, I thought I’d better point out that you made a mistake in your ruby script!! As all we programmers know, it should have been:

def sum_numbers(string_of_numbers)
numbers = string_of_numbers.split(‘,’).map(&:to_i)
sum = 0

numbers.each do |num|
    sum += num

Or at least that what ChatGPT thinks.

I’ve got no chance!!


We have no idea what you actually posted to ChatGPT, since you did not post the exact prompt you used.

I have already fully tested what I posted in the Ruby console and anyone can see it works perfectly :slight_smile:

The following is not ChatGPT data, it is real data in the Ruby console.

irb(main):027:1* def sum_numbers(string_of_numbers)
irb(main):028:1* numbers = string_of_numbers.split(' ').map(&:to_i)
irb(main):029:1* sum = 0
irb(main):031:2* numbers.each do |num|
irb(main):032:2* sum += num
irb(main):033:1* end
irb(main):035:1* puts sum
irb(main):036:0> end
=> :sum_numbers
irb(main):037:0> sum_numbers("200 192 187 187 196 190 188 198 204 191 175 198 18
8 189 186 198 189 187 180 179")
=> nil

You may be confused @stuartmitch.home , ChatGPT is not considered “an authority”… so if you want to confirm Ruby code, you should be familiar with how to code in Ruby, etc.

ChatGPT and all GPT models are tools for domain experts to use, these model DO NOT replace domain experts.

What programing language are you an expert or at least somewhat proficient in @stuartmitch.home ? I will prompt Chatty to produce a method in your area of expertise or experience.


This expression in your code you posted @stuartmitch.home is very different than what I posted. You are splitting a string with a comma, but in your original string, there is no comma.

See the issue? We have no idea where you got that code or how you prompted the GPT to generate a completion.


Loosen up kid. I was just joking!

Yeah, am I’m really busy and trying to help you as my wife begs me to take her outside in the great weather here.

(And I am not a kid.)

Good luck and take care.

It seems ChatGPT is not actually preforming calculation. It got the answer right sometimes but not all the time.

The same as asking ChatGPT to write a code, its answer doesn’t really match with the result of executing the actual code.

I asked whether ChatGPT can be used as calculator:
“Are you a calculator beside being an wikipedia?”
It answered with:
“… I can also perform more complex calculations using algorithms and formulas. So yes, I can function as a calculator.”

I then asked:
“Give me the ternair of 256”
It answered with:
“The ternary representation of 256 is 22222, where each digit represents a power of 3:
2 * 3^4 + 2 * 3^3 + 2 * 3^2 + 2 * 3^1 + 2 * 3^0 = 2 * 81 + 2 * 27 + 2 * 9 + 2 * 3 + 2 * 1 = 256”
But this is actually 242
It should be 100111
1 * 3^5 + 0 * 3^4 + 0 * 3^3 + 1 * 3^2 + 1 * 3^1 + 1 * 3^0 = 243 + 9 + 3 + 1 = 256

Hi @ErikB

You cannot “believe” anything ChatGPT says. ChatGPT is a chatbot based on generative AI tech.

ChatGPT has no idea about anything, it is simply predicting the next sequence of text based on the current text or prior sequence of text using probabilities.

Please search the forums before posting. Your question / comment has been posted countless time here, to be honest.

ChatGPT is based on a language model, it’s not a computer nor a calculator.


At this moment, I found out that solving the chatgpt calculation problem is more difficult than do a calculation.