Question: I'm a total JS noobie, and I'm trying to make it so that after one input is entered all of the numbers between 0 and that input are added up, including the input. Here is the basic pseudo code I'm trying to accomplish but i can't figure it out?

```
get count from user

loop up to count{

     add current number to sum

}

display sum

display breakline

loop up to count with a different loop type{

    add current number to sum

}

display sum

```

Answer: 
The fastest way to do this is by adding a sequence (looping not required):

```
let sum = input * (input + 1) / 2

```

[See this link for more information.](http://www.themathworld.com/math-tricks/adding-sequence-of-numbers.php)
Here it is the full code displaying you want:

```html
<HTML>
<HEAD>
<TITLE>JavaScript Form - Input Text Field</TITLE>
<SCRIPT Language="JavaScript">
<!--//
function showAndClearField(frm){
  if (frm.num.value == "")
      alert("Hey! You didn't enter anything!")
  else{
    var result = 0;
  var input = frm.num.value; //However you do it.
  for (var i = 1; i <= input; i++) {
    result += i;
  }
      alert("Result: " + result)
  }
  frm.firstName.value = ""
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="test">
<H2>Enter a number.</H2>
<INPUT TYPE="Number" NAME="num"><BR><BR>
<INPUT TYPE="Button" Value="Show and Clear Input" onClick="showAndClearField(this.form)">
</P>
</FORM>
</BODY>
</HTML>
```