For your fifth lab, you will play around with recursion. You will
need to write the following recursive functions
- public static int
multuply(int x, int y) Returns x * y. However, you
are not allowed to use multiplication (only addition!), and you are not
allowed to use any loops (only recursion!) You may assume
that x and y are positive
- public static void
printVertical(int x) Prints out x vertically. Thus,
if you called printVertical(4352); you should get printed to standard
out:
4
3
5
2
As above, you cannot use any loops, only recursion.
- public static int lg(int x)
returns log (base 2) of x. As above, no loops are allowed.
Only use the mathematical operators +, -, *, and /.
- public static int log(int
base, int x) returns log (base base) of x. As above, no
loops are allowed. Only use the mathematical operators +,
-, *, and /.
Grading
This lab is pretty simple, and the grading is as well:
- multiply
25 points
- printVertical
25 points
- lg 25 points
- log 25 points
Submission
All file(s) required for
your project should be in the folder
https://www.cs.usfca.edu/svn/<username>/cs112/Lab5/