Dutch's bit shifting is just the application of the standard formula for the summation of a geometric series.
For say day 5 the sum is 1 + 2 + 4 + 8 + 16 = 31
This is a geometric series with the start value of 1 (a) and a common ratio of 2 (r).
The standard result for the summation of a geometric series is:
a(1 - r^n)/(1 - r)
where r^n is r raised to the power n and n is the number of elements in the series to sum.
In this case a is 1 and r is 2. This then simplifies to :
(1 - 2^n)/(1 - 2) which is (1 - 2^n)/-1 which is 2^n -1
2^n in bits is simply 1 left shift n which in c++ is 1ul << n (where 1ul is 1 as type unsigned long)
n is simply the number of days. So the required answer is simply:
The brackets are needed as - has a higher precedence than <<. So without the brackets it would be evaluated as 1ul << (days - 1) which is not what is required.