Computer science
this assignment, we are going to create a class with a variety of recursive methods. Recall that a recursive method is one that calls itself repeatedly. Each time it
does so, it is operates on a smaller version of the original problem until a terminating (or base case) condition is reached.
fibonacci – this method accepts an integer parameter and returns an integer result. The value returned will be the Fibonacci number for input value n, where n is the
position in the sequence. Note that
fibonacci(0) = 0
fibonacci(1) = 1
fibonacci(n) = fibonacci(n – 1) + fibonacci(n – 2)
The method should output the current value of n at the start of each call. (See example below). You can use this link to verify your results:
http://www.miniwebtool.com/list-of-fibonacci-numbers/?number=100
pow – this method accepts one double parameter x and one integer parameter y and returns the value of x raised to the power y. Note that
pow(0, y) = 0
pow(x, 1) = x
pow(x, y) = x * pow(x, y – 1)
The method should output the current values of x and y at the start of each call. (See example below)
flipper – this method accepts a String parameter and returns a flipped or reversed version of the String. Note that
flipper(“a”) = “a”
flipper(“ab”) = “ba”
flipper(“abcd”) = “dcba”
The method should output the current String parameter the start of each call. (See example below)