How to Solve Euler 1 in JavaScript

Fri, Dec 4, 2015

Read in 1 minutes

The Euler 1 problem is fairly simple to solve. Most people intuitively know how to do it. Here is how I would do it in JavaScript.

From left to right we do:

  • create an array of 1000 elements
  • insert the index of each element as it’s value (effectively giving us a list from 1 to 1000
  • reduce that array so that each value that are a multiple of either 3, 5 or both is added to running sum

See Also

How to Read a file in JavaScript

Fri, Nov 27, 2015

Read more →

How to Parse Json in JavaScript

Tue, Sep 8, 2015

Read more →

How to write a TCP Echo server in Javascript

Fri, Aug 21, 2015

Read more →

How to Read from stdin in JavaScript

Thu, Aug 20, 2015

Read more →

How to Write Json in JavaScript

Thu, Aug 13, 2015

Read more →