Fixed the algorithm to run on the prime field pow(2,16)+1 by using long integers for arithmetic