readathonPages 🌶️
In a read-a-thon you read as many pages as the day number: 1 page on day 1, 2 pages on day 2, and so on. Write a method readathonPages that takes the first and last day you took part (first is at most last, and both days count) and returns the total number of pages you read on those days.
For example, readathonPages(1, 5) is 15, and readathonPages(4, 7) is 22 (4 + 5 + 6 + 7).
The loop should not always start at 1. What should its starting value be?
Use
for (int day = first; day <= last; day++) and add day to a running total each time.