Problem 377

Back to General discussions forum

michaeljshelton     2023-12-22 20:17:28

For the Sum of Digits Divisibility problem, there is a simple iterative approach that is easy enough to code up but too slow to use as a submission for the very large numbers in the test cases.

Without putting any solutions directly in the forum, I know there exists a way to calculate these solutions in O(1), but this also requires requires calculation of a "correction" factor. I can see that there exists a pattern to this correction factor, but I am not a genius mathematician to be able to calculate the correction factor directly from k.

Is there any chance to get help on the equation for at least how to generate the correction factor necessary to use the O(1) equation that solves the problem directly instead of using an iterative approach?

Thank you for any help, I did try not to give away any part of the problem in asking this question.

gardengnome     2023-12-22 21:03:23
User avatar

Do you have to calculate what you call the correction factor? How about a "mini brute-force" approach instead?

michaeljshelton     2023-12-22 21:17:51

Yea, That's a good point. It might be fast "enough" to do the iteration to simply calculate this correction factor then plug it into the rest of the equation. I'll try that and see if the processing can complete in a reasonable time. Thanks.

michaeljshelton     2023-12-22 22:15:45

I guess the pattern is more complex than I thought... Maybe I need to just do the simple iterative solution but in a language that is fast enough to complete for large numbers :-)

michaeljshelton     2023-12-22 22:51:26

Ok... from getting the "expected" values back from a failed submission, I see there is another pattern that does not require doing any sequencing.

Please login and solve 5 problems to be able to post at forum