Solution of second problem in PARI/GP.