Skip to content

Commit

Permalink
Merge pull request neetcode-gh#1564 from julienChemillier/patch-50
Browse files Browse the repository at this point in the history
Add 263 in c language
  • Loading branch information
Ahmad-A0 authored Dec 22, 2022
2 parents f616428 + f11c03f commit 8954592
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions c/263-Ugly-Number.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5.
Given an integer n, return true if n is an ugly number.
*/

bool isUgly(int n){
if (n<=0)
return false;
if (n==1)
return true;
if (n%3==0)
return isUgly(n/3);
if (n%2==0)
return isUgly(n/2);
if (n%5==0)
return isUgly(n/5);
return false;
}

0 comments on commit 8954592

Please sign in to comment.