Suppose that a,b∈Z and that b=b1b2, where b1 and b2 are relatively prime and greater than 1. Show that there exist unique integers a1,a2,n∈Z such that 0⩽ai<bi and
ba=b1a1+b2a2+n
Now let b=p1n1⋯pknk be the prime factorization of b. Deduce that ba can be written uniquely in the form
ba=p1n1q1+⋯+pknkqk+n
where 0⩽qi<pini and n∈Z. Express ba=3151 in this form.