diff --git a/Subtract the Product and Sum of Digits of an Integer b/Subtract the Product and Sum of Digits of an Integer new file mode 100644 index 0000000..6275b13 --- /dev/null +++ b/Subtract the Product and Sum of Digits of an Integer @@ -0,0 +1,16 @@ +class Solution { +public: + int subtractProductAndSum(int n) { + + int sum=0,mul=1; + + while(n!=0) + { + mul=mul*(n%10); + sum+=(n%10); + n=n/10; + } + + return (mul-sum); + } +};