10.5. More Mixed Up Code Practice¶
Try to solve each of the following. Click the Check Me button to check each solution. You will be told if your solution is too short, has a block in the wrong order, or you are using the wrong block. Some of the problems have an extra block that isn’t needed in the correct solution. Try to solve these on your phone or other mobile device!
The following method should recursively reverse the string that is passed in the parameter and return the reversed string. It if is passed “abcd” it should return “dcba”. It has one extra block that is not needed in a correct solution.
The following method should recursively return the fibonacci sequence of the first n numbers. The fibonacci (f) of f(0) is 0 and of f(1) is 1. The fibonacci of any other number is f(n-1) + f(n-2). It has one extra block that is not needed in a correct solution.
The following method should recursively replace all the spaces in the String str with dashes.
The following method should recursively count and return the number of 2’s that are present in the number.
The following method should recursively find and return the sum of the digits of int n.
The following method should recursively find and return the number of even digits in int n.
The following method should recursively find and print the factorial of int n. It has 1 extra block of code.