-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindDigits.java
More file actions
39 lines (29 loc) · 879 Bytes
/
FindDigits.java
File metadata and controls
39 lines (29 loc) · 879 Bytes
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
33
34
35
36
37
38
39
package hackerrank;
import java.util.Scanner;
public class FindDigits {
public static void main() {
// TODO Auto-generated method stub
// int inputNumber=Integer.parseInt(args[0]);
Scanner in = new Scanner(System.in);
while(in.hasNextLine())
{
Integer inputNumber=in.nextInt();
if(inputNumber<10)
continue;
String inputString=inputNumber.toString();
int count=0;
int digit=0;
for(int i=0;i<inputString.length();i++)
{
char c=inputString.charAt(i);
String s=""+c;
digit=Integer.parseInt(s);
if(digit!=0 && inputNumber%digit==0)
{
count++;
}
}
System.out.println(count);
}
}
}