One-page version suitable for printing.
Statistics:
mean 23.400 (351.000/15) stddev 5.017 median 24.000 midrange 19.000-28.250 # avg 1 9.33 / 10 2 7.60 / 10 3 6.47 / 10
Suppose a user executes the following run() method and types the numbers 4 and 17.
public static void run() {
int a = IO.readInt();
int b = IO.readInt();
int m = 0;
int n = b;
while(m < n) {
m += a;
n -= a;
}
IO.println(m - n);
}
a b m n
Say we've defined the following method.
public static int f(int n) {
IO.print(n);
return 1 + n;
}
IO.println(3 + f(2 + f(1)));
Fill in run() so that, when executed, the method will compute the factorial of a number the user types. A user executing the method should see the following, for example. (Boldface indicates what the user types.)
Number: 4 24
import csbsju.cs160.*;
public class FindFactorial {
public static void run() {
}
}