Recursive Functions
Do the best you can - credit for real work.
1. Create a recursive method called power(int x, int y) that will
compute x to the y power.
2. Create a recursive method called sumOfDigits(int x) that will
compute the sum of all digits in x. Like 457 would return 16.
3. EC Create a recursive method called public ArrayList<Integerjavab> allFactors (int
x) that will return all factors of x.
4. EC2:The numbers in the fibonacci series may also be calculated neatly using recursion
-
The first two fibonacci numbers are 0 and 1, respectively
-
Every other fibonacci number is calculated by adding the previous two
-
Thus the series begins: 0, 1, 1, 2, 3, 5, 8, 13,…
|