< Summary

Information
Class: LeetCode.Algorithms.UglyNumber.UglyNumberMath
Assembly: LeetCode
File(s): D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\UglyNumber\UglyNumberMath.cs
Line coverage
72%
Covered lines: 13
Uncovered lines: 5
Coverable lines: 18
Total lines: 47
Line coverage: 72.2%
Branch coverage
75%
Covered branches: 6
Total branches: 8
Branch coverage: 75%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
IsUgly(...)75%9872.22%

File(s)

D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\UglyNumber\UglyNumberMath.cs

#LineLine coverage
 1// --------------------------------------------------------------------------------
 2// Copyright (C) 2025 Eugene Eremeev (also known as Yevhenii Yeriemeieiv).
 3// All Rights Reserved.
 4// --------------------------------------------------------------------------------
 5// This software is the confidential and proprietary information of Eugene Eremeev
 6// (also known as Yevhenii Yeriemeieiv) ("Confidential Information"). You shall not
 7// disclose such Confidential Information and shall use it only in accordance with
 8// the terms of the license agreement you entered into with Eugene Eremeev (also
 9// known as Yevhenii Yeriemeieiv).
 10// --------------------------------------------------------------------------------
 11
 12namespace LeetCode.Algorithms.UglyNumber;
 13
 14/// <inheritdoc />
 15public class UglyNumberMath : IUglyNumber
 16{
 17    /// <summary>
 18    ///     Time complexity - O(log n)
 19    ///     Space complexity - O(1)
 20    /// </summary>
 21    /// <param name="n"></param>
 22    /// <returns></returns>
 23    public bool IsUgly(int n)
 324    {
 325        if (n == 0)
 026        {
 027            return false;
 28        }
 29
 530        while (n % 2 == 0)
 231        {
 232            n /= 2;
 233        }
 34
 435        while (n % 3 == 0)
 136        {
 137            n /= 3;
 138        }
 39
 340        while (n % 5 == 0)
 041        {
 042            n /= 5;
 043        }
 44
 345        return n == 1;
 346    }
 47}

Methods/Properties

IsUgly(System.Int32)