Skip to content

Commit 53f47da

Browse files
author
Ann Witbrock
committed
Server Fib function: remove guard for negative input ( to match python tutorials)
Client: remove extra example calls
1 parent cb591b0 commit 53f47da

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

java/RPCClient.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,6 @@ public static void main(String[] argv) {
5858
System.out.println(" [x] Requesting fib(30)");
5959
response = fibonacciRpc.call("30");
6060
System.out.println(" [.] Got '" + response + "'");
61-
System.out.println(" [x] Requesting fib(-1)");
62-
response = fibonacciRpc.call("-1");
63-
System.out.println(" [.] Got '" + response + "'");
64-
System.out.println(" [x] Requesting fib(a)");
65-
response = fibonacciRpc.call("a");
66-
System.out.println(" [.] Got '" + response + "'");
6761
}
6862
catch (Exception e) {
6963
e.printStackTrace();

java/RPCServer.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ public class RPCServer {
99
private static final String RPC_QUEUE_NAME = "rpc_queue";
1010

1111
private static int fib(int n) {
12-
if (n > 1) return fib(n-1) + fib(n-2);
13-
else return n;
12+
if (n ==0) return 0;
13+
if (n == 1) return 1;
14+
return fib(n-1) + fib(n-2);
1415
}
1516

1617
public static void main(String[] argv) {

0 commit comments

Comments
 (0)