Hint for part 2 - set of numbers from 0 to P-1 with arithmetic done in mod P (e.g mul(a,b) returns (a * b) % P ) is a field if P is prime - or in other words regular algebra works like you would expect it to. -- Sasha Pachev Fast Running Blog. http://fastrunningblog.com Run. Blog. Improve. Repeat.