-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheasiest.java
32 lines (30 loc) · 1.01 KB
/
easiest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.util.Scanner;
public class easiest {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
String linea = sc.next();
if (Integer.parseInt(linea) != 0) {
int multiplicador = 11;
while (true) {
int res = Integer.parseInt(linea) * multiplicador;
if (new easiest().sumDigits(linea) == new easiest().sumDigits(String.valueOf(res))) {
System.out.println(multiplicador);
break;
} else {
multiplicador++;
}
}
} else {
break;
}
}
}
public int sumDigits(String line) {
int sumLinea = 0;
for (int i = 0; i < line.length(); i++) {
sumLinea += Integer.parseInt(String.valueOf(line.charAt(i)));
}
return sumLinea;
}
}