What is the sum of the first 100 positive integers? The formula for the sum of integers \(1\) through \(n\) is \(n(n+1)/2\). Define \(n=100\) and then use R to compute the sum of \(1\) through \(100\) using the formula. What is the sum?
With the code below you can compute the sum for the first 20 integers. You can copy and past the code in the R console to evaluate that the code.
20*(20+1)/2
However, we can also define a variable n to re-use the formula for other values of n
n <- 20
n*(n+1)/2
We can reuse the same code and redefine n so to repeat the calculation for n=25.
n <- 25
n*(n+1)/2
Now, adjust the code from the example to calculate the sum of the first 100 integers.