Is it ethical to post an exam question and answer to the internet?
There is an alternative that avoids the question asked here entirely and would even be more valuable to your readers.
Think about what it is about that equation (or other question) that makes it interesting. Abstract from that to a more general question that also covers the specific case.
Then present a way of thinking about that class of problems that will lead someone to a successful solution. Explain the thinking process. Explain any connections to similar things. Etc.
Then, you can publish that freely.
Note that words, but not ideas, can be bound by copyright. Take the idea and expand it. Anyone is free to do that.
As suggested in Ethan Bolkers comment: Ask the teacher, either directly or through the student and aim for a joint or collaborative web posting.
Copying the problem from the exam verbatim is at the very least questionable. I'm not sure whether they are legal copyright issues but you shouldn't do it anyway. Using the key idea of the problem, rephrased in your own words and with different numbers is fine. It is also highly unlikely that the teacher came up with this completely new problem. More likely the teacher also just found it somewhere and adapted it for their exam.