[Java/Python 3] Straight forword code w/ analysis.
\njava\n    public int subtractProductAndSum(int n) {\n        int sum = 0, prod = 1;\n        while (n > 0) {\n            int digit = n % 10;\n            sum
\n```java\n    public int subtractProductAndSum(int n) {\n        int sum = 0, prod = 1;\n        while (n > 0) {\n            int digit = n % 10;\n            sum += digit;\n            prod *= digit;\n            n /= 10;\n        } \n        return prod - sum;       \n    }\n```\n```python\n    def subtractProductAndSum(self, n: int) -> int:\n        sum, prod = 0, 1\n        while n:\n            digit = n % 10\n            sum += digit\n            prod *= digit\n            n //= 10\n        return prod - sum\n```\nsimplification using `divmod`, credit to **@ajc2001**\n```python\n    def subtractProductAndSum(self, n: int) -> int:\n        sum, prod = 0, 1\n        while n:\n            n, digit = divmod(n, 10)\n            sum += digit\n            prod *= digit\n        return prod - sum\n```\n**Analysis:**\nTime: `O(logn)`, space: `O(1)`.
[]