Server Fib function: remove guard for negative input ( to match python tutorials)
Client: remove extra example calls
This commit is contained in:
parent
cb591b06b2
commit
53f47dad55
@ -58,12 +58,6 @@ public class RPCClient {
|
||||
System.out.println(" [x] Requesting fib(30)");
|
||||
response = fibonacciRpc.call("30");
|
||||
System.out.println(" [.] Got '" + response + "'");
|
||||
System.out.println(" [x] Requesting fib(-1)");
|
||||
response = fibonacciRpc.call("-1");
|
||||
System.out.println(" [.] Got '" + response + "'");
|
||||
System.out.println(" [x] Requesting fib(a)");
|
||||
response = fibonacciRpc.call("a");
|
||||
System.out.println(" [.] Got '" + response + "'");
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -9,8 +9,9 @@ public class RPCServer {
|
||||
private static final String RPC_QUEUE_NAME = "rpc_queue";
|
||||
|
||||
private static int fib(int n) {
|
||||
if (n > 1) return fib(n-1) + fib(n-2);
|
||||
else return n;
|
||||
if (n ==0) return 0;
|
||||
if (n == 1) return 1;
|
||||
return fib(n-1) + fib(n-2);
|
||||
}
|
||||
|
||||
public static void main(String[] argv) {
|
||||
|
Loading…
Reference in New Issue
Block a user