- Mathematical, Puzzles

Check if a number can be represented as the sum of numbers with at least one digit equal to K

Given integers N and K, the task is to check if a number can be represented as the sum of numbers that have at least one digit equal to K.Example:Input: N = 68, K = 7Output: YESExplanation: 68 = (27 + 17 + 17 + 7). Each number has atleast one digit equal to 7.Input: N = 23, K = 3Output: YESExplanation: 23 itself contains a digit equal to 3.Approach: The given problem can be solved by using simple concepts of math. Follow the steps below to solve the problem:Initialize a variable temp to k, and also take a counter say count, assign it with 0Iterate till the last digits of temp and N are not equal and at each iterationIncrement the value of temp by kKeep a count of iterations and break the loop if the count becomes greater than 10Check if the last digits of temp and N are equal, and if the value of temp