about | help | code help+videos | done | prefs |
Look at the ones-digit and tens digit of n. When they are the same, return the value of that digit. When they are different, return the sum of the digits. It doesn't matter if n is a single digit or more than 2 digits. magicValue(1) → 1 magicValue(502) → 2 magicValue(11) → 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
Copyright Nick Parlante 2017 - privacy