My first impulse was Disney's The Computer Wore Tennis Shoes, but that was a movie, of course (which was later remade). Somewhat unsurprisingly, I've found reference to a novelization. Could that be what you're looking for?
Here's a plot description from Wikipedia:
Dexter Reilly (Kurt Russell) and his friends attend small, private Medfield College, which cannot afford to buy a computer. The students persuade wealthy businessman A.J. Arno (Cesar Romero) to donate an old computer to the college. Arno is the secret head of a large illegal gambling ring, which used the computer for its operations.
While installing a replacement part during a thunderstorm, Reilly receives an electric shock and becomes a human computer. He now has superhuman mathematical talent, can read and remember the contents of an encyclopedia volume in a few minutes, and can speak a language fluently after reading one textbook. His new abilities make Reilly a worldwide celebrity, and Medfield's best chance to win a televised quiz tournament with a $100,000 prize.
And, for the ending:
Reilly single-handedly leads Medfield's team in victories against other colleges. During the tournament, a trigger word causes Reilly to unknowingly recite on television details of Arno's gambling ring. Arno's henchmen kidnap Reilly and plan to kill him, but his friends help him escape. During the escape Dexter suffers a concussion which, during the tournament final against rival Springfield State, gradually returns his mental abilities to normal; one of Reilly's friends, however, is able to answer the final question ("What is the geographic center of the contiguous United States?"). Medfield wins the $100,000 prize, and Arno is arrested.