-
-
Save awaemmanuel/c16a2ecd4de0358c86d26e41bd611c6d to your computer and use it in GitHub Desktop.
Revisions
-
cangoal revised this gist
Apr 7, 2016 . 2 changed files with 21 additions and 21 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,21 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ // public boolean isUgly(int num) { if (num == 0) return false; while (num % 2 == 0) num /= 2; while (num % 3 == 0) num /= 3; while (num % 5 == 0) num /= 5; return num == 1; } // public boolean isUgly(int num) { if(num <= 0) return false; int[] factor = {2, 3 ,5}; int i = 0; while(num != 1){ int remainder = num % factor[i]; if(remainder == 0) num = num / factor[i]; else if(i < factor.length-1) i++; else if(i == factor.length-1) break; } return num == 1; } -
cangoal revised this gist
Sep 24, 2015 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,12 @@ // public boolean isUgly(int num) { if (num == 0) return false; while (num % 2 == 0) num /= 2; while (num % 3 == 0) num /= 3; while (num % 5 == 0) num /= 5; return num == 1; } // public boolean isUgly(int num) { if(num <= 0) return false; int[] factor = {2, 3 ,5}; -
cangoal revised this gist
Sep 15, 2015 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,11 @@ public boolean isUgly(int num) { if (num == 0) return false; while (num % 2 == 0) num /= 2; while (num % 3 == 0) num /= 3; while (num % 5 == 0) num /= 5; return num == 1; } public boolean isUgly(int num) { if(num <= 0) return false; int[] factor = {2, 3 ,5}; -
cangoal created this gist
Aug 24, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ public boolean isUgly(int num) { if(num <= 0) return false; int[] factor = {2, 3 ,5}; int i = 0; while(num != 1){ int remainder = num % factor[i]; if(remainder == 0) num = num / factor[i]; else if(i < factor.length-1) i++; else if(i == factor.length-1) break; } return num == 1; }