-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.txt
87 lines (69 loc) · 1.1 KB
/
example.txt
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
83
84
85
86
87
var x, y, z, q, r, n, f : int;
int multiply ()
{
var arg_1, arg_2 : int;
arg_1 := x;
arg_2 := y;
z := 0;
while arg_2 > 0 do
{
if z%2 != 0 then z := z + arg_1 else {};
arg_1 := 2*arg_1;
arg_2 := arg_2/2;
};
return z;
}
void divide ()
{
var w : int;
r := x;
q := 0;
w := y;
while w <= r do w := 2*w;
while w > y do
{
q := 2*q;
w := w/2;
if w <= r then
{
r := r - w;
q := q + 1;
}
else
{
};
};
return;
}
int gcd()
{
var f, g : int;
f := x; g := y;
while f != g do
{
if f < g then g := g - f else {};
if g < f then f := f - g else {};
};
z := f;
return z;
}
int fact (a:int)
{
var f, g :int;
f := 1;
if a > 1 then
{
g := a-1;
f := a* fact (g);
}
else {};
return f;
}
main
{
var res, f:int;
?x; ?y; res := multiply (); !res;
?x; ?y; divide (); !q; !r;
?x; ?y; res := gcd (); !res;
?n; f := fact (n); !f;
}