DEV Community

That programming book you never finished

Arik on June 22, 2018

Tell me if this sounds familiar: You walk into a bookstore, browse through some shelves and run into a programming book about a subject you alwa...
Collapse
 
billcarverdev profile image
BillCarver

Based on the opening, I was looking for strategies on finishing books.

Collapse
 
saviobosco profile image
Saviobosco

Me too

Collapse
 
itsjoel29 profile image
itsjoel29

I was expecting the same U_u

Collapse
 
allecto profile image
Paula Hasstenteufel

Yes.

Collapse
 
sgsfak profile image
Stelios Sfakianakis

Personally I would think the following is the exact translation in Python of the math formula shown in the article:

  sum(2*i for i in range(1, 101))

(well... if you ignore the fact that the upper limit of range in not inclusive so I need to put 101 instead of 100)

So now that you know about Sigmas etc. you can read The Art of Computer Programming ;-)

Collapse
 
brandonarnold profile image
Brandon Arnold • Edited

Try reducing computation by finding a closed form instead of writing a loop. Here, the closed form is f(n) = n*(n+1) (e.g. f(100) = 100*101 = 10100):

f(n) = S[1..n] 2*i     definition
     = 2 * S[1..n] i   pull out the coefficient
     = 2 * n*(n+1)/2   by triangular number formula
     = n*(n+1)         cancel the twos
Collapse
 
jgamgam profile image
Joaquim

Not the topic I expected, bit was a nice read anyway.

Collapse
 
cben profile image
Beni Cherniavsky-Paskin

github.com/Jam3/math-as-code is a "cheatsheet" explaining tons of math notation by showing equivalent JavaScript code, similar to how this article explained Ξ£.

Collapse
 
benfaught profile image
Benjamin Faught • Edited

Mathematical Notation: A Guide for Engineers and Scientists
I bought this little jewel just for this situation:
amazon.com/Mathematical-Notation-G...

Collapse
 
dothtm profile image
dotHTM

*Greek…

I πŸ’– Math.

Collapse
 
clsource profile image
Camilo

I recommend this site brilliant.org for math and science stuff :)

Collapse
 
willrieske profile image
WillRieske

Misleading headline. But now high school math is coming back to me...