-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalgo31.cs
43 lines (39 loc) · 1.06 KB
/
algo31.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.Metrics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;
namespace HelloWorld
{
class Program
{
class Algorithm
{
public static bool IsSquare(int n)
{
int number = (int)Math.Sqrt(n);
if (number * number == n)
{
return true;
}
return false;
}
public static bool IsSquare2(int n)
{
if (n < 0)
{
return false;
}
return (int)(Math.Sqrt(n) ) * (int)(Math.Sqrt(n) ) == n;
}
}
static void Main(string[] args)
{
int number = 25;
Console.WriteLine(Algorithm.IsSquare(number));
Console.WriteLine(Algorithm.IsSquare2(number));
}
}
}