Find Me Out

 Coding Problem Keys 

 Find Me Out 

 Problem Statement 

For a given number N (0 < N <= 100), little Johnny wants to find out the minimum positive integer X divisible be N, where the sum of digits of X is equal to N, and X is not equal to N.

 Note 

If such a number X does not exist, then output should by -1.

 Input Format 

The first line contains an integer N.

 Output Format 

The first line contains the minimum positive integer X.

 Sample Input/Output 1 

 Input 

9

 Output 

18

 Explanation 

Starting from 1, the minimum positive integer to be returned by the function is 18 which is divisible by the sum of the digits of 18 is equal to 9, and 18 is not equal to 9. Therefore 18 is returned as the output.

 Sample Input/Output 2 

 Input 

10

 Output 

190

 Explanation 

Starting from 1, the minimum positive integer to be returned by the function is 190 which is divisible by 10, the sum of the digits of 190 is equal to 10, and 190 is not equal to 10. Therefore, 190 is returned as the output.

 Solution 

 Programming Language: Python 3 Language 

n=int(input())
i=1;x=1;v=0;s=0;flag=0
while i<100:
    s=0
    if x%n==0:
        v=x
        while x>0:
            rem=x%10
            s+=rem
            x//=10
    x=i*n
    i+=1
    if n==s and n!=v:
        flag=1
        break
    else:
        flag=0
if flag==1:
    print(v)
else:
    print("-1")

# Published By PKJCODERS

 (Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.) 

Comments

Unknown said…
I am getting error in line 2
PKJCODERS Admin said…
For doubts reach us via Telegram channel

Link is available in the notification section.

- PKJCODERS Admin

Popular Posts

Top Scoring Batsman - TEST ODI 20-20

Largest Possible Number With Digits

Highly Profitable Months

Minimum Sum of Non-Negative Elements

Count Embedded Integers in String

String - Vowels Position Sum

Desktop Products