# Put 1 grain of rice on the first square of a chess board, 2 on the second
# 4 on the third, 8 on the fourth, and so forth. Find how many grains of rice
# are on the board after you get to n squares
#
# Matt Bishop, ECS 36A, Winter 2019
#
nsquares = 10 # number of squares
totalrice = 0 # number of grains of rice on the board
for i in range(nsquares):
grains = 2 ** i
print("square", i, "-- grains in this square:", grains, end=" ")
totalrice = totalrice + grains
print("total so far:", totalrice)
print("total number of grains of rice on", nsquares, "squares is", totalrice)