I'm having some trouble understanding the problem. Could you provide an example for test 7?
My understanding of the problem leads me to believe the answer should be 1600: 1 + 7 + 8 + 49 + 50 + 56 + 343 + 344 + 350 + 392
You've almost got it, bmtran. You are missing 7^2 + 7^1 + 7^0 = 57 in your example. Put that in, remove the 392 (since that's term #11 in the sequence) and you have the correct answer.
Thanks, that makes sense. I was under the impression that it could only be the sum of 2 distinct powers based on the example.
I've changed the description to make it a bit clearer that you can use any number of terms in the sequence. Hope this helps.
The problem wants all unique combinations of distinct powers of a given base up to a point. If we forget some factors it will overflow, if we repeat sequences, their sum will not match the test cases.
2 1 0
3 1 0
3 2 0
3 2 1
and so on (and resulting numbers must be sorted if we are not following their natural order)
It is not clear at all, James, that we must sum all possible unique combinations of exponents for a base. However, it is a good problem.
Is there any constraint on using toolboxes ? because the solution i proposed works fine if you have the communication system toolbox installed.
Adel, there are some toolboxes that Cody is able to use, and some that it can't. Since this (otherwise valid) solution doesn't seem to work, it looks like the communication system toolbox is not installed for Cody. Sadly, that's something I can't control while making the problems.
Cf, Problem 337.
It's too bad that Cody doesn't have access to nansum()...
but it now has sum(...,'omitnan')
And it worked just the same. Thanks.
I had to know...
given 3 sides, find area of this triangle
Determine if a Given Number is a Triangle Number
Multiples of a Number in a Given Range
Swap two numbers
Kurchan 5x5 - Optimal Score
How brilliant are you?
With apologies to William Blake
Must be in the front row...
Sleeping Queens 1
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