java & python | 0ms & 100% Faster | iteration & recursion
Java Recurive Solution :\n\n\nclass Solution {\n    public int subtractProductAndSum(int n) {\n        return (RecPro (n, 1) - RecSum (n, 0));\n    }\n     stat
**Java Recurive Solution :**\n\n```\nclass Solution {\n    public int subtractProductAndSum(int n) {\n        return (RecPro (n, 1) - RecSum (n, 0));\n    }\n     static int RecSum(int n, int sum) {\n\n        if (n == 0) {\n            return sum;\n        }\n        \n        return RecSum(n / 10 , sum += n % 10);\n    }\n\n    static int RecPro(int n, int pro) {\n\n        if (n == 0) {\n            return pro;\n        }\n        \n        return RecPro(n / 10 , pro *= n % 10);\n    }\n}\n```\n\n**Python Iterative Solution :**\n\n```\nclass Solution(object):\n    def subtractProductAndSum(self, n):\n\t\n        Sum = 0\n        Product = 1;\n        while n > 0:\n            rem = n % 10;\n            Sum += rem;\n            Product *= rem;\n            n /= 10;\n            \n        return Product - Sum    \n```
['Recursion', 'Python', 'Java']