Writing recursive function that converts decimal to octal


Complete the following exercises:

1) Write a function that uses recursion that converts a decimal number to octal (base 8). The function should accept a single integer and return a String containing the base 8 equivalent.

2) Write a recursive function that implement the following functions:

a)  x0 = 1
xn = x * xn-1 if n > 0

b) x0 = 1
xn = (xn/2)2 if n > 0 and n is even
xn = x * (xn/2)2 if n> 0 and n is odd

3) How many multiplications will the functions you wrote in problem 2 perform when computing 319? 332?
How many recursive calls will the functions make when computing 319? 332?

4) Write a recursive function that implements the following function:
f(1) = 1; f(2) = 1; f(3) = 1; f(4) = 3; f(5) = 5
f(n) = f(n-1) + 3 * f(n-5) for all n > 5

Make the function as efficient as possible.

5) Compute f(n) for n = 6, 7, 12, 15

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Writing recursive function that converts decimal to octal
Reference No:- TGS0995

Expected delivery within 24 Hours