Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
73
rated 0 times [  74] [ 1]  / answers: 1 / hits: 51363  / 9 Years ago, sat, june 6, 2015, 12:00:00

I'm working on the Project Euler problems (currently question 13).



For this question I have to find the first 10 digits of the sum of 100 numbers all of a size similar to this:



91,942,213,363,574,161,572,522,430,563,301,811,072,406,154,908,250


I think I could use something like Java's BigInteger, but I started solving the problems in JavaScript (I'm trying to boost my js abilities for work), and I would like to continue using it, even to solve this problem.



I'd like to stick to pure JS if possible.


More From » types

 Answers
6

You are going to need a javascript based BigInteger library. There are many to choose from. Here is one https://github.com/peterolson/BigInteger.js



You can use it like this



var n = bigInt(91942213363574161572522430563301811072406154908250)
.plus(91942213363574161572522430563301811072406154908250);

[#66307] Thursday, June 4, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
yvettel

Total Points: 517
Total Questions: 101
Total Answers: 102

Location: Vanuatu
Member since Wed, Oct 14, 2020
4 Years ago
yvettel questions
Tue, Jul 27, 21, 00:00, 3 Years ago
Thu, Aug 13, 20, 00:00, 4 Years ago
Wed, Apr 15, 20, 00:00, 4 Years ago
Wed, Apr 1, 20, 00:00, 4 Years ago
;