about | help | code help+videos | done | prefs |
Write a method that returns the "Common Digit Sum" of the two positive integer parameters. Those two integers will have the exact same number of digits (as each other). The "Common Digit Sum" is the sum of all the digits that are the same digits in the same position in both numbers. For example, 241578 and 781524 have 1 and 5 in the same position, so their "Common Digit Sum" would be 6. You are not allowed to use strings in any way. Recursion is allowed (encouraged?) but NOT required. In the future, I might give you this same problem, but have the added difficulty that the two numbers need not be the same length. However, for now, you can assume the two numbers WILL be the same length! Yeah! That makes it easier! rrr2commonDigitSum(3, 3) → 3 rrr2commonDigitSum(3, 7) → 0 rrr2commonDigitSum(12345, 62547) → 6 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 280
Copyright Nick Parlante 2017 - privacy