Divisible by Its Digits
Time limit2sMemory limit128 MB
Given N, find the smallest integer whose decimal digits start with N and that is divisible by every nonzero digit of N.
- Level
Medium5 of 10
- Topics
- Math, Number theory, Simulation
- Solved
- No attempts yet
Problem
You are given a positive integer . Find the smallest integer whose decimal representation starts with and that is divisible by every nonzero digit appearing in .
Digits equal to 0 are ignored for the divisibility condition.
Input
The first line contains a positive integer .
Output
Print the smallest integer satisfying the condition.