You are viewing a single comment's thread. Return to all comments →
The test cases get too large for JS to represent as a 'Number'. Instead, use 'BigInt'. https://javascript.info/bigint
function superDigit(n, k) { var value = Number((BigInt(n) * BigInt(k)) % BigInt(9)); return value ? value : 9; }
Seems like cookies are disabled on this browser, please enable them to open this website
Recursive Digit Sum
You are viewing a single comment's thread. Return to all comments →
The test cases get too large for JS to represent as a 'Number'. Instead, use 'BigInt'. https://javascript.info/bigint
function superDigit(n, k) { var value = Number((BigInt(n) * BigInt(k)) % BigInt(9)); return value ? value : 9; }