8000 Merge pull request #19 from juanarbol/master · AllAlgorithms/javascript@c882198 · GitHub
[go: up one dir, main page]

Skip to content

Commit c882198

Browse files
authored
Merge pull request #19 from juanarbol/master
Sum of n natural numbers
2 parents 124fc69 + dde576e commit c882198

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

math/naturalNumbersSum.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Change this as the limit of numbers to be added
2+
// const lastNumber = 4 // 1+2+3+4
3+
const lastNumber = 5 // 1+2+3+4+4
4+
5+
6+
let sum = lastNumber*(1+lastNumber)*0.5
7+
console.log(sum)

0 commit comments

Comments
 (0)
0