Subtract the Product and Sum of Digits of an Integer
给一个数, 返回它的每个位上的数的积和和的差.
class Solution {
public int subtractProductAndSum(int n) {
int p = 1;
int s = 0;
while(n > 0) {
p *= n % 10;
s += n % 10;
n /= 10;
}
return p - s;
}
}