Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create 0263-ugly-number.js #1761

Merged
merged 1 commit into from
Jan 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Create 0263-ugly-number.js
  • Loading branch information
AP-Repositories authored Dec 30, 2022
commit 629157b00b6a0628ad85141e1499e657cb937c10
9 changes: 9 additions & 0 deletions javascript/0263-ugly-number.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var isUgly = function(n) {
if(n <= 0)
return false;

for(const p of [2, 3, 5])
while(n % p == 0)
n = n / p;
return n == 1;
};