We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 83a0bbd commit 1ca0f6eCopy full SHA for 1ca0f6e
java/728_Self_Dividing_Numbers.java
@@ -0,0 +1,35 @@
1
+class Solution {
2
+ public List<Integer> selfDividingNumbers(int left, int right)
3
+ {
4
+ LinkedList list = new LinkedList();
5
+ for(int i = left; i <= right; i++)
6
7
+ if(isSelfDiving(i))
8
+ list.add(i);
9
+ }
10
+ return list;
11
12
+
13
+ public boolean isSelfDiving(int num)
14
15
+ int digit = num % 10;
16
+ int temp = num;
17
+ boolean isTrue = true;
18
+ while(temp != 0)
19
20
+ if(digit == 0 || num % digit != 0)
21
22
+ isTrue = false;
23
+ break;
24
25
+ else
26
27
+ temp /= 10;
28
+ digit = temp%10;
29
30
31
+ return isTrue;
32
33
34
35
+}
0 commit comments