MCPcopy Create free account
hub / github.com/codedecks-in/LeetCode-Solutions / isUgly

Method isUgly

Java/Ugly-Number.java:2–22  ·  view source on GitHub ↗
(int num)

Source from the content-addressed store, hash-verified

1class Solution {
2 public boolean isUgly(int num) {
3 if(num == 0) return false;
4 if(num == 1) return true;
5
6 if(num % 2 == 0){
7 num = num / 2;
8 return isUgly(num);
9 }
10
11 if(num % 3 == 0){
12 num=num / 3;
13 return isUgly(num);
14 }
15
16 if(num % 5 == 0){
17 num = num / 5;
18 return isUgly(num);
19 }
20
21 return false;
22 }
23}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected