Skip to content

Commit 9f49240

Browse files
authored
Create 1837-sum-of-digits-in-base-k.js
1 parent 6334a70 commit 9f49240

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

1837-sum-of-digits-in-base-k.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @param {number} n
3+
* @param {number} k
4+
* @return {number}
5+
*/
6+
const sumBase = function(n, k) {
7+
let str = n.toString(k)
8+
let res = 0
9+
for(let ch of str) res += +ch
10+
11+
return res
12+
};

0 commit comments

Comments
 (0)