Ad
  • Custom User Avatar
  • Custom User Avatar

    Once solved, you can check out the author's (@myjinxin2015) solution to see how they did it without the need for BigInt or imported modules.

  • Custom User Avatar

    Oh cool, I didn't know you could import libraries. Thanks for the advice; I've found some clues about modular arithmetic which I think will help.

  • Custom User Avatar

    There are libraries which help with that (bignumber.js or native support for big numbers available since Node 10) but if you are going to calculate n^n, it won't really help you. The number will get so big, you will run out of memory.
    Additionally, if you structure your solution correctly, you will not even need big numbers. This problem can be solved in domain well below Number.MAX_SAFE_INTEGER.

  • Custom User Avatar

    Any tips on how to work with big numbers in JS? Some of the tests produce integers in scientific notation which I can't seem to figure out how to deal with.