The easy solution uses a loop, but there is also a formula for this, which is discussed in Chapter 3.