# Addition of all integer numbers from 1 - 100 (loop)

**URL:** <https://discourse.processing.org/t/addition-of-all-integer-numbers-from-1-100-loop/26237>\
**Category:** Beginners\
**Created:** [December 14, 2020, 3:28pm UTC](https://discourse.processing.org/t/addition-of-all-integer-numbers-from-1-100-loop/26237 "2020-12-14T15:28:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hullah](https://avatars.discourse-cdn.com/v4/letter/h/ee59a6/32.png) [@hullah](https://discourse.processing.org/u/hullah)\
**Post date:** [December 14, 2020, 3:28pm UTC](https://discourse.processing.org/t/addition-of-all-integer-numbers-from-1-100-loop/26237/1 "2020-12-14T15:28:14Z")

</div>

hey guys,

I am an absolutely beginner who wants to add all integer numbers from 1 to 100 ( in a loop) and print the result with println(). I know that I should use a for() loop but how can I add each element of 1-100 in order to get the sum?

like this : 0+1+2+3+4+5+6 …+100 = …?

thanks for your help!

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [December 14, 2020, 4:48pm UTC](https://discourse.processing.org/t/addition-of-all-integer-numbers-from-1-100-loop/26237/2 "2020-12-14T16:48:51Z")

</div>

HI @hullah  
See the documents  
[https://processing.org/reference/addassign.html](https://processing.org/reference/addassign.html)

```auto
int sum;

void setup() { 
  for (int i = 0; i <= 100; i++) {
    sum += i;
  }
  println(sum);
}

```

---

<div class="post-metadata">

**Author:** ![hullah](https://avatars.discourse-cdn.com/v4/letter/h/ee59a6/32.png) [@hullah](https://discourse.processing.org/u/hullah)\
**Post date:** [December 14, 2020, 5:51pm UTC](https://discourse.processing.org/t/addition-of-all-integer-numbers-from-1-100-loop/26237/3 "2020-12-14T17:51:10Z")

</div>

thanks a lot noel! 🙂

---

<div class="post-metadata">

**Author:** ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Post date:** [December 15, 2020, 10:02pm UTC](https://discourse.processing.org/t/addition-of-all-integer-numbers-from-1-100-loop/26237/4 "2020-12-15T22:02:53Z")

</div>

if you need an equasion for it use

```auto
int n = 5;
println( ( n*(n+1)/2 ));

```

n ( n + 1 ) / 2 = ( n^2 + n ) / 2

its a simple way to do it

---

<div class="post-metadata">

**Author:** ![hullah](https://avatars.discourse-cdn.com/v4/letter/h/ee59a6/32.png) [@hullah](https://discourse.processing.org/u/hullah)\
**Post date:** [December 23, 2020, 11:02am UTC](https://discourse.processing.org/t/addition-of-all-integer-numbers-from-1-100-loop/26237/5 "2020-12-23T11:02:50Z")

</div>

that’s great! thanks !

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [December 26, 2020, 1:47am UTC](https://discourse.processing.org/t/addition-of-all-integer-numbers-from-1-100-loop/26237/6 "2020-12-26T01:47:41Z")

</div>

Hello,

Additional references:

> **[Summation](https://en.wikipedia.org/wiki/Summation)**
>
> In mathematics, summation is the addition of a sequence of any kind of numbers, called addends or summands; the result is their sum or total. Beside numbers, other types of values can be summed as well: functions, vectors, matrices, polynomials and, in general, elements of any type of mathematical objects on which an operation denoted "+" is defined.
> Summations of infinite sequences are called series. They involve the concept of limit, and are not considered in this article.
> The summation of an...

`:)`
