Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
How to increase max integer in javascript?
function sum_of_mul_3_5(n) {
  const max_3 = Math.floor((n - 1) / 3);
  const max_5 = Math.floor((n - 1) / 5);
  const max_15 = Math.floor((n - 1) / 15);
  const total_3 = (3 * max_3 * (max_3 + 1)) / 2;
  const total_5 = (5 * max_5 * (max_5 + 1)) / 2;
  const total_15 = (15 * max_15 * (max_15 + 1)) / 2;
  console.log(total_3 + total_5 - total_15);
}

sum_of_mul_3_5(1000000000);
233333333166666700

The output is not correct.

Using c++ long data type, the correct answer is:

233333333166666668

How do I increase the max value of javascript Number data type so that the function sum_of_mul_3_5 will output the correct result?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!