ARINDAM-PAUL-DE / subtract-the-product-and-sum

leetcode question no 1281

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

subtract-the-product-and-sum

leetcode question no 1281

class Solution { public: int subtractProductAndSum(int n) {

int prod = 1; int sum = 0 ;

while(n != 0){ int digit = n%10; prod = prod*digit; sum = sum+digit; n/10; } int answer = prod - sum; return answer; } };

About

leetcode question no 1281