Algos for number theory