Number Theory algorithms