Definition at line 5 of file main.cpp.
◆ sumBase()
| int Solution::sumBase |
( |
int |
n, |
|
|
int |
k |
|
) |
| |
|
inline |
Definition at line 8 of file main.cpp.
9 {
10 if (k < 2 || k > 10)
11 throw runtime_error("Wrong base");
12
13 int sum = 0;
14 while (n > 0)
15 {
16 sum += n % k;
17 n /= k;
18 }
19 return sum;
20 }
Referenced by main().
The documentation for this class was generated from the following file: