about | help | code help+videos | done | prefs |
Write a function sumDigits(number, numDigits) that returns the sum of the individual digits in a parameter number that has numDigits digits. For example, sumDigits(1234, 4) should return the value 1 + 2 + 3 + 4 = 10. (Hint: use a for loop and integer division (// and %).) sumDigits(324, 3) → 9 sumDigits(1976, 4) → 23 sumDigits(19760, 5) → 23 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Copyright Nick Parlante 2017 - privacy