Recursion Exercise
Complete the following recursive methods -- try not to use your
notes.
//Precondition: n >= 1
//Postcondition: returns the sum of the first n numbers
static int sum(int n) {
}
//Precondition: n >= 0
//Postcondition: returns n!
static long factorial(long n) {
}
//Precondition: n >= 0
//Postcondition: returns xn
static long power(long x, long n) {
}
//Precondition: 0 <= size <= array.length
//Postcondition: returns true if value is in array
false otherwise
static boolean search(int[] array, int size, int value) {
}
//Precondition: n >= 1
//Postcondition: returns the nth fibonacci number
static int fib(int n) {
}