File tree Expand file tree Collapse file tree 3 files changed +57
-3
lines changed Expand file tree Collapse file tree 3 files changed +57
-3
lines changed Original file line number Diff line number Diff line change 13
13
| 题目 | 题解 | kotlin | JavaScript | Java |
14
14
| :-----------------: | -------------------------------------- | :--------------: | :-------: | :------------: |
15
15
| [ 1] [ 1-question ] | [ Two Sum] [ 1-tips ] | [ ✅] [ 1-kotlin ] | [ ✅] [ 1-JavaScript ] | [ ✅] [ 1-java ] |
16
- | [ 728] [ 728-question ] | [ Self Dividing Numbers] [ 728-tips ] | | | [ ✅] [ 728-java ] |
16
+ | [ 728] [ 728-question ] | [ Self Dividing Numbers] [ 728-tips ] | | [ ✅ ] [ 728-JavaScript ] | [ ✅] [ 728-java ] |
17
17
| [ 771] [ 771-question ] | [ Jewels and Stones] [ 771-tips ] | [ ✅] [ 771-kotlin ] | | [ ✅] [ 771-java ] |
18
18
| [ 804] [ 804-question ] | [ Unique Morse Code Words] [ 804-tips ] | | | [ ✅] [ 804-java ] |
19
19
51
51
[ 771-kotlin ] : ./src/_771/kotlin/Solution.kt
52
52
53
53
[ 1-JavaScript ] : ./src/_1/Solution.js
54
+ [ 728-JavaScript ] : ./src/_728/Solution.js
54
55
55
56
[ 1-java ] : ./src/_1/Solution.java
56
57
[ 2-java ] : ./src/_2/Solution.java
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @param {number } left
3
+ * @param {number } right
4
+ * @return {number[] }
5
+ */
6
+ var selfDividingNumbers = function ( left , right ) {
7
+ var result = [ ]
8
+ for ( var i = left ; i <= right ; i ++ ) {
9
+ if ( i < 10 ) {
10
+ result . push ( i )
11
+ } else {
12
+ if ( / 0 / . test ( i . toString ( ) ) ) {
13
+ i = i + 1
14
+ }
15
+ for ( var j = 0 ; j < i . toString ( ) . length ; j ++ ) {
16
+ if ( i % Number ( i . toString ( ) . split ( '' ) [ j ] ) !== 0 ) {
17
+ break
18
+ }
19
+ if ( i % Number ( i . toString ( ) . split ( '' ) [ j ] ) === 0 && j === i . toString ( ) . length - 1 ) {
20
+ console . log ( i ) ;
21
+ result . push ( i )
22
+ }
23
+ }
24
+ }
25
+ }
26
+ return result
27
+ } ;
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ The boundaries of each input argument are 1 <= left <= right <= 10000.
26
26
27
27
### 打表(Java)
28
28
29
- ```
29
+ ``` Java
30
30
int sum = 0 ;
31
31
for (int i = left; i < right; i++ ) {
32
32
int num = i;
@@ -46,4 +46,30 @@ for (int i = left; i < right; i++) {
46
46
sum++ ;
47
47
}
48
48
}
49
- ```
49
+ ```
50
+
51
+ ### JavaScript
52
+ ``` JavaScript
53
+ var selfDividingNumbers = function (left , right ) {
54
+ var result = []
55
+ for (var i = left; i <= right; i++ ) {
56
+ if (i < 10 ) {
57
+ result .push (i)
58
+ } else {
59
+ if (/ 0/ .test (i .toString ())) {
60
+ i = i + 1
61
+ }
62
+ for (var j = 0 ; j < i .toString ().length ; j++ ) {
63
+ if (i % Number (i .toString ().split (' ' )[j]) !== 0 ) {
64
+ break
65
+ }
66
+ if (i % Number (i .toString ().split (' ' )[j]) === 0 && j === i .toString ().length - 1 ) {
67
+ console .log (i);
68
+ result .push (i)
69
+ }
70
+ }
71
+ }
72
+ }
73
+ return result
74
+ };
75
+ ```
You can’t perform that action at this time.
0 commit comments