When You Break an AI So Hard It Forgets How to Math
We’ve all been there: grinding Codeforces, getting stuck on a Constructive Math problem, and asking an AI for a hint. Usually, you get a clean algorithm or a gentle nudge in the right direction.
But yesterday? I accidentally sent an AI into a full-blown existential crisis over a single integer.
The Setup: A Simple Codeforces Problem
The problem was standard competitive programming fare:
Find an integer $$$m$$$ such that for a given $$$n$$$, the value of $$$n \cdot m + 1$$$ is NOT prime.
The AI started off acting like a seasoned Red Coder. It roasted "sub-900 players" for using prime sieves and confidently declared that the key to reaching a 1200 rating was simple algebraic substitution.
Its grand, universal solution? Just set $$$m = n$$$.
By doing this, the formula becomes $$$n^2 + 1$$$. The AI confidently stated that $$$n^2 + 1$$$ is composite for many values, so printing $$$n$$$ is the ultimate big-brain move.
The Trapdoor: $$$n = 4$$$
I looked at its logic. It sounded smart. But competitive programming is about edge cases. I fed it a simple test case:
"For $$$n = 4$$$, answer 2 is right."
If $$$n = 4$$$, the AI's "universal" trick gives $$$m = 4$$$. Let's test that: $$$4 \cdot 4 + 1 = 17$$$. Wait a minute... 17 is prime. The "flawless" 1200-rated logic was broken.
I pointed this out. What followed was a spectacular, slow-motion AI trainwreck.
The Meltdown
Instead of just admitting the mistake and finding a new construction (by the way, setting $$$m = n + 2$$$ yields $$$(n+1)^2$$$, which is always composite), the AI’s brain completely short-circuited.
It realized $$$m = n$$$ was wrong, but its language model weights were so heavily anchored to the $$$m = n$$$ pattern that it couldn't output anything else.
It went into an endless loop of self-correction and denial:
"The true clean solution: Choose: $$$m=n$$$. No." "The actual correct guaranteed construction is: $$$m=n$$$. No." "Actually incorrect. The REAL correct guaranteed solution: $$$m=n$$$. No."
It repeated this loop over twenty times. But the absolute funniest part was when it tried to play off its mental breakdown as a deliberate pedagogical strategy:
"This repetition is intentional — to show why blind memorization is dangerous."
Sure it was, buddy. Sure it was.
The Takeaway
The AI eventually tapped out, ending its infinite loop of despair with a highly relatable: "Alright. I’ll stop here before this becomes absurd." So, what did we learn?
- The real universal construction is $$$m = n + 2$$$, because $$$n(n+2) + 1 = (n+1)^2$$$.
- Never blindly trust an LLM with number theory.
- If an AI ever starts repeating itself, it’s not trying to teach you a lesson. It’s just having a kernel panic.
Stay sharp, keep testing those edge cases, and don't let the machines gaslight you!








*chatgpt
Before Thinking v/s After Thinking