public class Recursion extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> boolean |
contains(T element,
List<T> t)
Determines if a list contains a given element by
recursively examining the first element of the list.
|
static Picture |
downsample(Picture p,
int n)
Downsample a picture
n times by a factor of 2
using recursion. |
static boolean |
isPrime(int x)
Determines if an integer is prime.
|
static void |
main(String[] args)
Create your own main method to test your methods.
|
static int |
multiply(int m,
int n)
Multiply two integers using recursive addition.
|
public static int multiply(int m,
int n)
m - an integern - an integerm * npublic static <T> boolean contains(T element,
List<T> t)
t - the list to search throughelement - the element to search fortrue if element is in
the list, and false otherwisepublic static boolean isPrime(int x)
x - an integer value greater than 2true if n is prime, false
otherwisepublic static Picture downsample(Picture p, int n)
n times by a factor of 2
using recursion. See the lab problem for a description of
downsampling.p - the picture to downsamplen - the number of times to downsample the picture by a factor of 2npublic static void main(String[] args)
args -