chatgpt is not a computer, or a claculator, but rather a text completion engine.
Using GPT-4, if I add a function to calculate prime, then if I ask it to calculate, I think it's going to get it every time by responding with the function call parameters.
Now admitedly chatgpt doesnt really give you that ability, unless you use a plugin maybe?
But chatgpt is genrally a text completion engine and is not good or supposed to be good at math.
It's does completion... give it context, and it completes text.
Ask it to make you happy, and it will. It doesnt know, it doesnt think it doesnt understand, it just completes text