If a chessboard were to have wheat placed upon each square such that one grain were placed on the first square and each successive square after had double the amount of grains as the square before. How many grains of wheat would be on the chessboard at the finish?
Assume the chess board is n by n squares.
Solution Stats
Problem Comments
7 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers193
Suggested Problems
-
Make the vector [1 2 3 4 5 6 7 8 9 10]
53339 Solvers
-
3818 Solvers
-
Given a window, how many subsets of a vector sum positive
873 Solvers
-
5387 Solvers
-
Given a square and a circle, please decide whether the square covers more area.
1832 Solvers
More from this Author4
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Shouldn't the solution for n=-1 be NaN, rather than 'NaN' which is a character array?
I agree with Ken , we expect NaN and not the string 'NaN'
I believe you should also change the assert for the case n=-1 to be isequalwithnan, since isequal(NaN,NaN) is false.
yeap you have just rescored the problem but you need to use isequalwithnan,
actually you need to use isequalwithequalnans
tests 5 and 6 does not work properly. those numbers are out of precision, and for test 6 it couldn't be fixed even with uint64 used instead of type double
This problem is simply wrong. The right answer is
sum(1:2^(n^2-1))
if we where to sum ALL the grains on the board....