You will be given three numbers: base, nstart, and nend. Write a MATLAB script that will compute the sum of a sequence of both the distinct powers of base as well as sums of distinct powers of base. Your sequence should start with the 'nstart'th term and end with the 'nend'th term. For example:
The first several sums of the distinct powers of 4 are:
Since nstart=2 and nend=6 in this example, you take the second through the sixth terms of this sequence. The correct output would be 4+5+16+17+20, or 62. Notice that the number 8 does not occur in this pattern. While 8 is a multiple of 4, 8=4^1+4^1. Because there are two 4^1 terms in the sum, 8 does not qualify as a sum of distinct powers of 4. You can assume that all three will be integers, base>1, and that nstart<nend. Good luck!