From 3a9b485307f6f2d34535df2c2b6c1f6a2756fec3 Mon Sep 17 00:00:00 2001 From: Guillaume Desktop Date: Sat, 20 Sep 2025 19:13:08 +0200 Subject: [PATCH] feature: added 0263 cs --- csharp/0263-ugly-number.cs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 csharp/0263-ugly-number.cs diff --git a/csharp/0263-ugly-number.cs b/csharp/0263-ugly-number.cs new file mode 100644 index 000000000..123c1cb1b --- /dev/null +++ b/csharp/0263-ugly-number.cs @@ -0,0 +1,32 @@ +public class Solution +{ + public bool IsUgly(int n) + { + while (n != 0) + { + if (n == 1) + { + return true; + } + + if (n % 2 == 0) + { + n /= 2; + } + else if (n % 3 == 0) + { + n /= 3; + } + else if (n % 5 == 0) + { + n /= 5; + } + else + { + break; + } + } + + return false; + } +} \ No newline at end of file