-
Notifications
You must be signed in to change notification settings - Fork 0
/
Test2702.cs
82 lines (68 loc) · 1.67 KB
/
Test2702.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace practice_4th_semester
{
internal class Test2702
{
public static int G(int x, int y)
{
if (y == 0) return x;
return G(y, x % y);
}
public static int Calc(int n)
{
int res = 1;
if (n > 1) res = 1 + Calc(n - 1);
Console.WriteLine($"{res} \t {n}");
return res;
}
public static int Calc2(int n)
{
int res = 1;
if (n > 1)
{
res = Calc2(n - 1) + Calc2(n - 2);
Console.WriteLine($"{res} \t {n}");
}
return res;
}
public static int F0(int n)
{
int sum = 0;
int step = 1;
while (sum < n)
{
for (int j = 0; j < step; j++)
sum++;
step *= 2;
}
return sum;
}
public static int F1(int n)
{
int sum = 0;
for (int i = 0; i < n; i++)
{
for (int j = 0; j * j < n; j++)
{
//Console.WriteLine($"{j * j}\t {n}");
sum++;
}
}
return sum;
}
public static int F2(int n)
{
int sum = 0;
for (int j = 0; j * j < n; j++)
{
//Console.WriteLine($"{j * j}\t {n}");
sum++;
}
return n * sum;
}
}
}