New Machar School pupils are celebrating after scooping first prize in a challenging maths competition.