publicstaticintsubtractProductAndSum(int n){int product=1;int sum=0;int k=n;while(k>0){int tem=k%10;sum+=tem;product*=tem;k=k/10;}returnproduct-sum;} Runtime:0 ms, faster than100.00%of Java online submissions for Subtract the Product and Sum of Digits of an Integer. Memory Usage...
1281. Subtract the Product and Sum of Digits of an Integer # 题目 # Given an integer number n, return the difference between the product of its digits and the sum of its digits. Example 1: Input: n = 234 Output: 15 Explanation: Product of digits = 2 *
Given an integer numbern, return the difference between the product of its digits and the sum of its digits. 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 ...
Given an integer numbern, return the difference between the product of its digits and the sum of its digits. Example 1: Input: n = 234Output: 15Explanation:Product of digits = 2 * 3 * 4 = 24 Sum of digits = 2 + 3 + 4 = 9 Result = 24 - 9 = 15 Example 2: Input: n = 4...
1281. Subtract the Product and Sum of Digits of an Integer* https://leetcode.com/problems/subtract-the-product-and-sum-of-digits-of-an-integer/ 题目描述 Given an integer number n, return the difference between the product of its digits and the sum of its di...
1281. Subtract the Product and Sum of Digits of an Integer Given an integer number n, return the difference between the product of its digits and the sum of its digits. publicintsubtactProductAndSum(intn){intproduct=1;intsum=0;while(n>0){product*=n%10;sum+=n%10;n=n/10;}returnprod...
Given an integer number n, return the difference between the product of its digits and the sum of its digits. 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 ...
1281. Subtract the Product and Sum of Digits of an Integer 2019-12-19 05:33 −Given an integer number n, return the difference between the product of its digits and the sum of its digits. Example 1: Input: n = 234 Out...
Subtract减去,the sum of和,digit数字,whole number整数,greater than 大于,result 结果,divisible整除, 由弃九法,选C.结果一 题目 If you subtract the sum of the digits of a whole number greater than from the number itself, the result must be divisible by .A.5B.6C.9D.12 答案 C相关...
and subtract the sum of its digits from the integer.The largest integer that must divide the result is . A.1 B.3 C.9 D.27相关知识点: 试题来源: 解析 C 对于任意大于100的整数,减去其每一位数字的和.一定能整除这一结果的最大整数是多少? greater than:大于;subtract:减去;digits:数字;integer:...