-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtinyMath.cs(deprecated)
61 lines (56 loc) · 1.27 KB
/
tinyMath.cs(deprecated)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
public class tinyMath
{
public static decimal ans;
public static void Add(decimal add1, decimal add2)
{
ans = add1 + add2;
}
public static void Subtract( decimal sub1, decimal sub2)
{
ans = sub1 - sub2;
}
public static void Divide(decimal div1, decimal div2)
{
ans = div1 / div2;
}
public static void Multiply(decimal mul1, decimal mul2)
{
ans = mul1 * mul2;
}
public static void Square(decimal sqr)
{
ans = sqr * sqr;
}
public static void Cube(decimal cube)
{
ans = cube * cube;
ans = ans * cube;
}
public static void Power(decimal num, int power)
{
if (power == 1) { ans = num; }
else if (power == 0) { ans = 1; }
else if (power < 0) { Console.WriteLine("Unsupported"); ans = 0; }
else
{
int current = 1;
ans = num;
while (current < power)
{
current++;
ans = ans * num;
}
}
}
public static void Factorial(decimal num)
{
tinyMath.ans = 1;
int counter = 1;
while (counter < num)
{
counter++;
ans = ans * counter;
}
}
}