For the
given number 'N' (0 <N<= 100), little Johnny wants to find out the
minimum positive integer 'X' divisible by 'N', where the sum of digits of 'X'
is equal to 'N' and 'X' is not equal to 'N'.
Note: If such an 'X' number does not exist, then output should be - 1.
Input Specification:
Answers
Answered by
19
Explanation:
For the
given number 'N' (0 <N<= 100), little Johnny wants to find out the
minimum positive integer 'X' divisible by 'N', where the sum of digits of 'X'
is equal to 'N' and 'X' is not equal to 'N'.
Note: If such an 'X' number does not exist, then output should be - 1.
Input Specification:
Answered by
54
Answer:
def findNum (n):
testnum = n
while testnum <= 1000:
tempnum = testnum
sum = 0
while tempnum > 0:
sum = sum + (tempnum mod 10)
tempnum = int (tempnum / 10)
if sum == n:
return testnum
testnum = testnum + n
return -1
Similar questions