Skip to content

Commit ac9e8eb

Browse files
authored
feat: add ts solution to lc problem: No.2520 (doocs#1879)
1 parent 78fc1fb commit ac9e8eb

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

Diff for: solution/2500-2599/2520.Count the Digits That Divide a Number/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,18 @@ function countDigits(num: number): number {
132132
}
133133
```
134134

135+
```ts
136+
function countDigits(num: number): number {
137+
let ans = 0;
138+
for (const s of num.toString()) {
139+
if (num % Number(s) === 0) {
140+
ans++;
141+
}
142+
}
143+
return ans;
144+
}
145+
```
146+
135147
### **Rust**
136148

137149
```rust

Diff for: solution/2500-2599/2520.Count the Digits That Divide a Number/README_EN.md

+12
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,18 @@ function countDigits(num: number): number {
119119
}
120120
```
121121

122+
```ts
123+
function countDigits(num: number): number {
124+
let ans = 0;
125+
for (const s of num.toString()) {
126+
if (num % Number(s) === 0) {
127+
ans++;
128+
}
129+
}
130+
return ans;
131+
}
132+
```
133+
122134
### **Rust**
123135

124136
```rust

0 commit comments

Comments
 (0)