I'm alright with using const since it seems to be widely supported by the
latest browsers, but I'm not good with using "let" since it is not widely
supported yet.

I'll probably be using JavaScript soon at my job for some mobile/desktop
web UIs, so I want to make sure I'm practicing the more mainstream
JavaScript.


On Sun, Jan 26, 2014 at 12:56 AM, b0ri5 <notifications@github.com> wrote:

> In projecteuler/p0001/multiples_of_3_or_5.js:
>
> > +// param b is the first divisor
> > +// param c is the second divisor
> > +const sum_divisors = function(a, b, c) {
> > +  var bc = b * c;
> > +  // Get the count of b, c, and b*c multiples in (1, a)
> > +  var count_b = Math.floor((a - 1) / b);
> > +  var count_c = Math.floor((a - 1) / c);
> > +  var count_bc = Math.floor((a - 1) / bc);
> > +
> > +  // Get the sum of b, c, and b*c
> > +  var sum = arithmetic_sum(b, b, count_b);
> > +  sum += arithmetic_sum(c, c, count_c);
> > +  // Subtract b*c since we've double-counted it
> > +  sum -= arithmetic_sum(bc, bc, count_bc);
> > +
> > +  return sum;
>
> This might be more readable without declaring extra variables?
>
> return arithmetic_sum(a, Math.floor((n - 1) / a)) +
> arithmethic_sum(b, Math.floor((n - 1) / b) -
> arithmetic_sum(a * b, Math.floor((n - 1) / (a * b));
>
> Perhaps make (n - 1) a var? "const m = n - 1"?
>
> Also I think var can effectively not be used in harmony javascript and
> "let" and "cost" can always be used instead.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/b0ri5/solvents/pull/39/files#r9174526>
> .
>