Please include an explanation of how the results are obtained when a has more than one digit. Based on your existing Problem Statement pattern_sum(10,4) should be equal to EITHER 10 + 1010 + 101010 + 10101010 = 10203040 (if repeating 4 times) OR 10 + 1010 = 1020 (if ending the sequence with a 4-digit number).
After some experimentation, I found that you need to multiplying the digit by the increasing powers of 10. The first term is a*10^0. The second term is a*10^1. The third term is a*10^2, and so on. So (10,4) would be 10+100+1000+10000. Granted, the problem statement says "single digit" so 10 and 56 shouldn't really be valid numbers, but we've all messed up problem descriptions and test suites before.
if there are number like "10", "56" in test suite, what's the point for mentioning "single digit positive integers"? is there any misunderstanding about "single digit" between different culture?
The test cases with double-digit numbers have been removed to prevent future confusion. Also, additional single-digit test cases have been added.
Times 2 - START HERE
Summing Digits within Text
Matrix indexing with two vectors of indices
There are 10 types of people in the world
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