1281. 整数的各位积和之差
int subtractProductAndSum(int n){ int sum = 0; int plus = 1; while (n > 0) { int mod = n % 10; sum += mod; plus *= mod; n = n / 10; } return plus - sum; }
Please call me JiangYouDang!
int subtractProductAndSum(int n){ int sum = 0; int plus = 1; while (n > 0) { int mod = n % 10; sum += mod; plus *= mod; n = n / 10; } return plus - sum; }