. Write a recursive function that takes a string as an input and returns the reverse of the string. 2.Write a recursive function rec_string that produces the output shown below for the corresponding function calls. Write a main function to test the function. Method call rec_string(‘abcde’), will produce the following output: * e de cde bcde abcde Method call rec_string(‘abc’), will produce the following output: * c bc abc 3. Write a recursive function for Euclid's algorithm to find the greatest common divisor (gcd) of two positive integers. gcd is the largest integer that divides evenly into both of them.
1. Write a recursive function that takes a string as an input and returns the reverse of the string.
2.Write a recursive function rec_string that produces the output shown below for the corresponding function calls. Write a main function to test the function.
Method call rec_string(‘abcde’), will produce the following output: *
e
de
cde bcde abcde
Method call rec_string(‘abc’), will produce the following output: *
c
bc
abc
3. Write a recursive function for Euclid's
If p > q, the gcd of p and q is the same as the gcd of q and p % q.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images