-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcode60.py
More file actions
executable file
·61 lines (48 loc) · 1.42 KB
/
code60.py
File metadata and controls
executable file
·61 lines (48 loc) · 1.42 KB
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
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('188.166.133.53',11059))
data = s.recv(2048)
print data
data = s.recv(2048)
question = data.split(' ')
print question
#private int nextSmallestPrime (int n) {
# // Based on the Bertrand's postulate, for all n there exists a prime number smaller than 2n
# for (int i = n; i < 2 * n; i = i + 2) {
# // Switch to odd numbers if first is even
# if (i % 2 == 0) i++;
#
# int j = 2;
# for (; j < i/2 + 1; j++) {
# if (i % j == 0) break; // Non-prime, goto next i
# }
# if (i % j == 0) continue;
# else return i; // found prime
# }
#
# // Prime number not found, quitting.
# return n;
#}
for z in range(0, 200):
x = int(question[8][:1])
y = 2
for x in range(int(question[8][:-2]) + 1, 2 * int(question[8][:-2])):
if x % 2 != 0:
for y in range(2, x / 2 + 1):
if x % y == 0:
break
if x % y == 0:
continue
else:
print "Sending " + str(x)
s.send(str(x) + "\n")
break
data = s.recv(19)
print data
data = s.recv(512)
question = data.split(' ')
print question
data = s.recv(2048)
print data
#s.send(str(20) + "\n")
s.close()