about | help | code help+videos | done | prefs |
Write a method that counts how many times the digit 'targetDigit' appears within the positive integer parameter 'origNum'. The parameter 'targetDigit' will be a single non-negative integer. The parameter 'origNum' could be any positive integer. For example, if 'origNum' is 712114 and 'targetDigit' is 1, this method should return 3 since the digit 1 appears three times in the number 712114. Please note that you are NOT allowed to use ANY strings in solving this problem. Hint: Don't forget about the 'div' and 'mod' operators: / and % as these will be very helpful. nov4_2016_APSLHL_countDigits(5432, 4) → 1 nov4_2016_APSLHL_countDigits(78077, 7) → 3 nov4_2016_APSLHL_countDigits(78077, 8) → 1 ...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: 250
Copyright Nick Parlante 2017 - privacy