about | help | code help+videos | done | prefs |
Given a non-negative integer, count how many of its digits are 3. Here are some suggestions for this and several other problems where you have to process all the digits of a number. Suggestion #1: You can look at the last digit of a number using num % 10 Suggestion #2: You can cut off the last digit of a number by assigning num = num / 10 Suggestion #3: As long as num is still positive, you know there are still digits left in it that need to be processed. count3(73) → 1 count3(3534) → 2 count3(8) → 0 ...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: 200
Copyright Nick Parlante 2017 - privacy