"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in
message news:iqi5pt$f47$1@newscl01ah.mathworks.com...
> "J.C. Martinez" wrote in message
> <iqh4s8$em7$1@newscl01ah.mathworks.com>...
>> here's my code. I'm wondering what else I need to add to sum up all the
>> numbers at the end. a = input('Enter number of days you would like to
>> know the total of');
>> f(1) = .01;
>> for i = 2:a
>> f(i) = (2*f(i1));
>> end
>>
>> Would sum(sum(2:a)) work right before the "end"?
>          
> In this particular problem there is no need to do summation of any kind.
> The sum of all the terms can be expressed as
>
> .01*(2^a1)
>
> which is a special case of taking sums of geometric series.
>
> Your problem sounds like the famous tale of a king trying to award a
> subject for supposedly devising the game of chess. The subject made what
> seemed like a modest request. One penny on the first square, two on the
> next, four on the third, and doubling on each successive square.
> Presumably the king would have had to file for bankruptcy if he had
> attempted to pay for all sixtyfour squares.
I agree; when I first read the OP's message I assumed this was for homework
for a combinatorics or discrete mathematics class. Although the original
version I remember heading dealt not with coins but with grains of rice, the
Wikipedia entry puts how much rice would be on the chessboard into
perspective.
http://en.wikipedia.org/wiki/Wheat_and_chessboard_problem
"On the entire chessboard there would be 2^64 1 =
18,446,744,073,709,551,615 grains of rice, weighing 461,168,602,000 metric
tons, which would be a heap of rice larger than Mount Everest."
Hope the inventor was hungry :)

Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com
