```
function sumFirstN(n) {
let sum = 0;
if (n < 0) {
sum = NaN;
}
else {
for (let i = 1; i <= n; i += 1) {
sum+= 1;
}
}
return sum;
```

I dont get why it gives the output that it gives,

For example, input= 5 output= 15.

I dont get the formula and the principles behind it.

Could anyone help please?