3 ms·
> you should not, absolutely not translate math notation to code. I don't see a problem, if eg it helps with getting some intuition. Sure there is a formula f
by ta123456789 4y ago
> you should not, absolutely not translate math notation to code.
I don't see a problem, if eg it helps with getting some intuition.
Sure there is a formula for this example. But the point in the article of writing this sum as a for loop is to explain what the notation means.
For a programmer who is not familiar with sigma/pi notation for sum/product, explaining it with a for loop is a quick way to understand.
- SamBam 4y agoExactly, that was my take-away. You don't need to think of the Sum function as a for-loop every time you use Sum, but it certainly helps explain it to a programmer who doesn't have a sense of what Sum is, but knows what a for-loop is.