Problem 44523. Pattern Sum
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.
Solution CommentsShow comments
Problem Recent Solvers197
Convert from Base 10 to base 5
Calculate the Number of Sign Changes in a Row Vector (No Element Is Zero)
Side of an equilateral triangle
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!