-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquestion
46 lines (28 loc) · 1.44 KB
/
question
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
Now it is your turn to write code!
In this exercise, your goal is to implement a Sum RPC Unary API in a CalculatorService:
The function takes a Request message that has two integers, and returns a Response that represents the sum of them.
Remember to first implement the service definition in a .proto file, alongside the RPC messages
Implement the Server code first
Test the server code by implementing the Client
Example:
The client will send two numbers (3 and 10) and the server will respond with (13)
Good luck
---------------------------------------------------
Now it is your turn to write code!
In this exercise, your goal is to implement a Primes RPC Server Streaming API in a CalculatorService:
The function takes a Request message that has one integer, and returns a stream of Responses that represent the prime number decomposition of that number (see below for the algorithm).
Remember to first implement the service definition in a .proto file, alongside the RPC messages
Implement the Server code first
Test the server code by implementing the Client
Example:
The client will send one number (120) and the server will respond with a stream of (2,2,2,3,5), because 120=2*2*2*3*5
Algorithm (pseudo code):
k = 2
N = 210
while N > 1:
if N % k == 0: // if k evenly divides into N
print k // this is a factor
N = N / k // divide N by k so that we have the rest of the number left.
else:
k = k + 1
Good luck