Ad
  • Default User Avatar

    The idea of using Number.MAX_VALUE is not bad but if you want a valid result, you need n way lower than Number.MAX_VALUE
    If you want an accurate result, you would even need n lower than 2^53 (134217727 max) because:
    Math.pow(2, 53) == Math.pow(2, 53) + 1 >> true