Skip to content

Commit 2c5e36c

Browse files
authored
feat: add php solution to lc problem: No.0263 (#945)
1 parent 8d2a07b commit 2c5e36c

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

Diff for: solution/0200-0299/0263.Ugly Number/README.md

+20
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,26 @@ func isUgly(n int) bool {
150150
}
151151
```
152152

153+
### **PHP**
154+
155+
```php
156+
class Solution {
157+
/**
158+
* @param Integer $n
159+
* @return Boolean
160+
*/
161+
function isUgly($n) {
162+
while ($n) {
163+
if ($n % 2 == 0) $n = $n / 2;
164+
else if ($n % 3 == 0) $n = $n / 3;
165+
else if ($n % 5 == 0) $n = $n / 5;
166+
else break;
167+
}
168+
return $n == 1;
169+
}
170+
}
171+
```
172+
153173
### **...**
154174

155175
```

Diff for: solution/0200-0299/0263.Ugly Number/README_EN.md

+20
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,26 @@ func isUgly(n int) bool {
136136
}
137137
```
138138

139+
### **PHP**
140+
141+
```php
142+
class Solution {
143+
/**
144+
* @param Integer $n
145+
* @return Boolean
146+
*/
147+
function isUgly($n) {
148+
while ($n) {
149+
if ($n % 2 == 0) $n = $n / 2;
150+
else if ($n % 3 == 0) $n = $n / 3;
151+
else if ($n % 5 == 0) $n = $n / 5;
152+
else break;
153+
}
154+
return $n == 1;
155+
}
156+
}
157+
```
158+
139159
### **...**
140160

141161
```

Diff for: solution/0200-0299/0263.Ugly Number/Solution.php

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
/**
3+
* @param Integer $n
4+
* @return Boolean
5+
*/
6+
function isUgly($n) {
7+
while ($n) {
8+
if ($n % 2 == 0) $n = $n / 2;
9+
else if ($n % 3 == 0) $n = $n / 3;
10+
else if ($n % 5 == 0) $n = $n / 5;
11+
else break;
12+
}
13+
return $n == 1;
14+
}
15+
}

0 commit comments

Comments
 (0)