Given an integer number n, return the difference between the product of its digits and the sum of its digits.
&nbsp;
Example 1:

Input: n = 234
Output: 15 
Explanation: 
Product of digits = 2 * 3 * 4 = 24 
Sum of digits = 2 + 3 + 4 = 9 
Result = 24 - 9 = 15


Example 2:

Input: n = 4421
Output: 21
Explanation: 
Product of digits = 4 * 4 * 2 * 1 = 32 
Sum of digits = 4 + 4 + 2 + 1 = 11 
Result = 32 - 11 = 21


&nbsp;
Constraints:


	1 &lt;= n &lt;= 10^5


class Solution:
    def subtractProductAndSum(self, n: int) -> int:
        n_to_list = list(str(n))
        
        sum_of_digits = 0 
        for num in n_to_list:
            sum_of_digits = sum_of_digits + int(num)
        
        product_of_digits = 1
        for num in n_to_list:
            product_of_digits = product_of_digits * int(num)
            
        answer = product_of_digits - sum_of_digits
        
        return answer
class Solution {
    public int subtractProductAndSum(int n) {
        int mul=1,sum=0;
        while(n!=0){
            sum=sum+n%10;
            mul=mul*(n%10);
            n=n/10;
        }
        return mul-sum;
    }
}
class Solution {
public:
    int subtractProductAndSum(int n) {
        vector<int> digit;
        int product=1;
        int sum=0;
        while(n>0){
            digit.push_back(n%10);
            n/=10;
        }
        for(int i=0;i<digit.size();i++){
            product*=digit[i];
            sum+=digit[i];
        }
        return product-sum;

    }
};
var subtractProductAndSum = function(n) {
  let product=1,sum=0
  n=n.toString().split('')
  n.forEach((x)=>{
   product *=parseInt(x)
   sum +=parseInt(x)
  }
  )
    return product-sum
  };
Subtract the Product and Sum of Digits of an Integer