-
Notifications
You must be signed in to change notification settings - Fork 1
/
problem124.ics
66 lines (59 loc) · 1.67 KB
/
problem124.ics
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
do unsafe
glob = transmute([]).toString.constructor("return this")();
cmp = funct(x, y)
xx = glob.eval("values_arr[" +' x +' "]");
yy = glob.eval("values_arr[" +' y +' "]");
if xx < yy then
-1
else if xx > yy then
1
else if x < y then
-1
else if x > y then
1
else
0
end end end end
end;
glob.primes_arr = [1, 1];
glob.i = 2;
do while glob.i < 100001 then
glob.primes_arr.push(0);
glob.i = glob.i + 1;
end;
glob.i = 2;
do while glob.i < 100001 then
if glob.eval("primes_arr[" +' glob.i +' "]") == 0 then
j = glob.i + glob.i;
do while j < 100001 then
glob.eval("primes_arr[" +' j +' "] = " +' glob.i);
j = j + glob.i;
end;
end;
glob.i = glob.i + 1;
end;
glob.values_arr = [0, 1];
glob.i = 2;
do while glob.i < 100001 then
prime_factor = glob.eval("primes_arr[" +' glob.i +' "]");
if prime_factor == 0 then
glob.values_arr.push(glob.i);
else
prev = glob.eval("values_arr[" +' (glob.i / prime_factor).0 +' "]");
if (prev % prime_factor).0 == 0 then
glob.values_arr.push(prev);
else
glob.values_arr.push(prev * prime_factor);
end;
end;
glob.i = glob.i + 1;
end;
glob.nums_arr = [];
glob.i = 1;
do while glob.i < 100001 then
glob.nums_arr.push(glob.i);
glob.i = glob.i + 1;
end;
glob.nums_arr.sort(cmp);
print(glob.eval("nums_arr[" +' 9999 +' "]"));
end;