Algorithms using Number Theory concepts