Files
oop/labs/lab4_done/Utils/Utils.cs
2025-09-30 14:26:54 +03:00

45 lines
723 B
C#

class Utils
{
public static int Greater(int a, int b)
{
if (a > b)
return a;
else
return b;
}
public static void Swap(ref int a, ref int b)
{
int temp = a;
a = b;
b = temp;
}
public static bool Factorial(int n, out int answer)
{
int k;
int f = 1;
bool ok = true;
try
{
checked
{
for (k = 2; k <= n; ++k)
{
f = f * k;
}
}
}
catch (Exception)
{
f = 0;
ok = false;
}
answer = f;
return ok;
}
}