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 =/
Very nice problem for kids and adults alike.
Celentano's solution is efficacious.
That was fun :)
any math formula?
This user (mohamed elbesealy) appears to have gamed the system, with fraudulent "likes" of this unremarkable solution submitted by 'sock-puppet' accounts. —DIV
sum of sequential series
Of course, this solution use the formula from Carl Friedrich Gauss for the sum of the integers from 0 to n.
While the obvious solution is y = sum(1:2^x), that will fail miserably for x = 50. So the alternative is a looping solution, that generates the sum more intelligently. Here, the looping is done simply using recursion. In fact, we can even compute the exact sum for x =100, a problem that would take the brute force solution the lifetime of the universe.
This done in fractions of a second, even for symbolic inputs.
not sure why this is wrong.
Upper limit must be 2^n, according to the problem's title & Test Suite. (Not clear from the problem statement, though!)
I can't figure this out after 10+ tries. Someone please help? http://www.followthesteps.net/sky-contact-phone-number/
Colon notation is key.
ha ha ha
I can't figure this out after 10+ tries. Someone please help?
How this solution is possible?
Ha ha !
This solution can accept arrays of integers as x input
This solution accepts arrays, avoids the explicite creation of 1:2^n and calculates the expensive power once only.
A good example of a solution that does well on Cody's size measure, but which I wouldn't use for serious purposes.
Is the Point in a Circle?
intersection of matrices
Piecewise linear interpolation
Reverse the elements of an array
Rounding off numbers to n decimals
Count decimal digits of a number
Find the treasures in MATLAB Central and discover how the community can help you!
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office