Project Euler

Here are my notes on solving some project euler problems. Contains spoilers!

Helper functions

/**
 * Decorator function for timing one or more calls of a function.
 *
 * @param {Function} f Function to be timed and repeated.
 * @param {Number} [times=1] Number of times to call f.
 * @returns {*} result Last returned result of calling f.
 */
function timer(f, times) {
  var times = times || 1,
      t = times,
      args = [].slice.call(arguments, 2), result;
  console.time(f.name + " x " + times);
  while (t--) {
    result = f.apply(null, args);
  }
  console.timeEnd(f.name + " x " + times);
  return result;
}

Solved