18 Star 133 Fork 63

编程语言算法集 / C-Sharp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
PerfectSquareChecker.cs 669 Bytes
一键复制 编辑 原始数据 按行查看 历史
Gerson Jr 提交于 2023-12-30 10:33 . Switch to file-scoped namespaces (#430)
using System;
namespace Algorithms.Numeric;
/// <summary>
/// A perfect square is an element of algebraic structure that is equal to the square of another element.
/// </summary>
public static class PerfectSquareChecker
{
/// <summary>
/// Checks if a number is a perfect square or not.
/// </summary>
/// <param name="number">Number too check.</param>
/// <returns>True if is a perfect square; False otherwise.</returns>
public static bool IsPerfectSquare(int number)
{
if (number < 0)
{
return false;
}
var sqrt = (int)Math.Sqrt(number);
return sqrt * sqrt == number;
}
}
C#
1
https://gitee.com/TheAlgorithms/C-Sharp.git
git@gitee.com:TheAlgorithms/C-Sharp.git
TheAlgorithms
C-Sharp
C-Sharp
master

搜索帮助