io ho pensato a

p[i](n&m)/m;

che ne pensi?

forse è meno drastico...