Problem 189. Sum all integers from 1 to 2^n
Carl Gauss's approach seems to be efficient for our brains but not for matlab
There are TWO problems with the way this problem is stated. Find them both!
Just go with your gut on this one.
John D'Errico wrote up some great commentary on this problem and how to go about solving it. http://blogs.mathworks.com/community/2016/07/21/numerical-analyst-john-derrico-takes-a-stroll-through-cody/
try to put to numbers in a range and sum them up
Additional test cases have been added.
Good one :)
fun solving :)
fun problem =/
The question is soo easy that you won't be able to catch the trick soo easily.
Nice and easy beginners question using the sum function. Thanks Dimitris!
Solution CommentsShow comments
Problem Recent Solvers13003
Right Triangle Side Lengths (Inspired by Project Euler Problem 39)
More from this Author1
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!