A video of a U.S. maths professor playing a prank on his students on April Fools' Day has been viewed more than 2 million times.