Is it Jayden's Rescue (2002) by Vladimir Tumanov? I haven't seen the book, but I found this description at Amazon:
Alex hates math. No matter how hard he tries, he can never get it right. Until one day he finds a magical book in which an evil wizard king has imprisoned a queen — and the only way to save her is with math! To rescue her, Alex and his friends must solve 400 mathematical puzzles posed by a menagerie of monster guards — and before long, Alex is solving riddle after riddle. Will they be able to set Jayden free? An exciting fantasy fiction debut from Canadian author Vladimir Tumanov.
And I found this author's blurb at Alex Kasman's Mathematical Fiction site:
Contributed by Vlad Tumanov
I am the author of a children's math mystery novel entitled Jayden's Rescue and Published by Scholastic Canada. This novel's plot revolves around mathematical puzzles for the grades 4-6 level. The puzzles are in verse, and the solutions are provided following each puzzle. The three child protagonists have to solve these puzzles in order to save an imprisoned queen. Subsequently, the puzzle quest continues as the children must extricate themselves from the grasp of an evil sorcerer. The adventure ends with a final showdown, involving a combination of problem-solving skills and suspense.
This link was provided in a comment by the OP.
Update. Here is the back cover blurb; the text in brackets is my guess at what's obscured by a book dealer's sticker:
The evil sorceror-king is holding Queen Jayden captive in his castle, and only Alex, Vanessa and Sam can save her . . .
In his room one gloomy evening, Alex finds a fantasy book called Jayden's
Rescue. Before long, it dawns on him that, in some parallel world, Jayden is real — and really is in trouble. To help her, Alex and his friends have to solve the puzzles posed by a menagerie of monster guards. There are four hundred of them — one for each room in the cas[tle — and time is runni]ng out . . .
Here is the first puzzle:
I am the father of nine sons,
all one-eyed monster boys.
I keep an eye on all my lads,
as they play with their toys.
A three-eyed monster once dropped in
and brought his sons along.
Three bulging eyes were on each guest;
oh, what a blinking throng!
Together all the monsters
had exactly forty eyes.
How many three-eyed kids were there?
The numbers tell no lies.
And here, from the beginning of Chapter 4, about the magic book with stuck-together pages:
Alex now found himself at the bottom of the page, where a caption read: "Help Jayden answer this question and then turn the page."
"No way am I doing the math!" Alex said to himself. Impatient to continue reading the rest of the adventure, he tried to go on without working out the answer. But the page would not turn. No matter how hard he pulled, the page stayed glued to the next one. In fact, the whole rest of the book was stuck tight. Alex shook the book, flipped it upside down and even blew on it. Nothing helped.
Disgusted, Alex tossed the book onto his desk. What was this, a bad joke? Some kind of trick thing, like that teeth-blackening "toothpaste" sold in so-called magic shops? Alex laughed. "Some magic!" he said, and then, with dawning excitement, he breathed, "Magic . . ."
Slowly, Alex reached out and picked up the book again. Could it be? He would never have believed it if he hadn't had a magic pencil in his own hands not very long ago. The magic pencil! If he had it right now, Alex would gladly wear it down to a stump to help Jayden. But without the pencil, he could never figure out the first puzzle, let alone four hundred of them. Without the magic pencil,
Alex was useless, and Jayden was doomed.