fun derivative(p as polyn) as polyn
var i, result as polyn;
var c,e as int;
result = 0;
foreach i in p do
e = degree(i);
c = coeff(i,e);
if e>0 then
result = result + c * e * x ^ (e-1);
fi;
od;
return result;
nuf;
var p1, p2 as polyn;
p1 = -5 * x^3 + 2x^2 + 5x+10;
println("p1 is: ",p1);
p2 = derivative(p1);
println("Its derivative is: ",p2);
println("Their sum is: ",p1+p2);
println("Their product is: ",p1*p2);