Recursive Digit Sum

  • + 0 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; }