We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
HINT: use a recurrence based on the last 4 digits of the number. In order to compute the number of solutions of length n ending in ABCD, you can get it based on the number of solutions of length n-1 ending in XABC, for each X = 0 to 9.
The number of valid 4-digit states is way less than 10,000, I think it was 415.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Prime Digit Sums
You are viewing a single comment's thread. Return to all comments →
HINT: use a recurrence based on the last 4 digits of the number. In order to compute the number of solutions of length n ending in ABCD, you can get it based on the number of solutions of length n-1 ending in XABC, for each X = 0 to 9.
The number of valid 4-digit states is way less than 10,000, I think it was 415.