What I learned from writing six functions that all did the same thing
Jackson Bates
1K36

When famous mathematician Gauss was still at school, he had this lazy teacher who made his students add up the numbers from 1 to 100 by hand. After a few seconds Gauss raised his hand and answered 5050. He understood that instead of actually adding all these numbers, he could add 1 and 100 to get 101. Adding 2 and 99 gave the same result. He could do this exactly 50 times, so he calculated 101 times 50 instead of actually summing the numbers. I’m not sure if this story is told at schools outside of Germany, but that last solution is based on the same idea.

I don’t know how optimized division is in js, but shifting one bit to the right might be faster than dividing by 2.

Most of the time FCC makes the argument that going to university for computer science might be a waste of money. Something that I often agree with. But this right here is precisely the kind of thinking that gets taught at most universities. So if you’re into this functional programming it may be worth your time and money.