Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save mh-github/aa7a6fc7e7b3d586b731 to your computer and use it in GitHub Desktop.

Select an option

Save mh-github/aa7a6fc7e7b3d586b731 to your computer and use it in GitHub Desktop.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Solution {
public static void main(String args[]) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
long n = 0;
while (true) {
String line = br.readLine();
try {
n = Long.parseLong(line.trim());
} catch (NumberFormatException e) {
e.printStackTrace();
System.out.println("Enter a valid number between 0 and 100000");
}
if (n < 1 || n > 99999) {
System.out.println("Enter a number between 0 and 100000");
} else {
break;
}
}
long s = 0;
long itr = 0;
while (true) {
// itr += 5;
s = n * (++itr);
String str = String.valueOf(s);
char c = str.charAt(str.length() - 1);
if (c != '0' && c != '1')
continue;
int i = 2;
for (; i < 10; i++) {
if (str.indexOf(i + "") != -1) {
break;
}
}
if (i == 10) {
System.out.println(str);
break;
} else {
continue;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment