Question: Would this be 1 to 1: The function should return as Y the greatest common divisor (GCD) of X1 and X2, calculated using the Euclidean
Would this be 1 to 1:
The function should return as Y the greatest common divisor (GCD) of X1 and X2, calculated using the Euclidean algorithm (non-recursive version). Test your function with the following
inputs:
My guess is no because if we pass in a dvisor that has the same balue of X1 and X2 it would point to the same result.
The next one is:
BaseB: The function has two integer input values X and B, with variable X between 1 and 100,000 and base B between 2 and 10. The function should return as Y the value of X expressed as a base B number. Test your function with the following inputs:
X = 359 B = 2
X = 632 B = 3
X = 757 B = 5
X = 981 B = 8
X = 8046 B = 10
This I actually dont know if I got right here is my outputs:
| X1 | X2 | Output |
| 359 | 2 | 101100111 |
| 632 | 2 | 212102 |
| 757 | 5 | 11012 |
| 981 | 8 | 1725 |
| 8046 | 10 | 8046 |
Then this one is not one to one becasue we can have a different base expodent so it would be easy to create one that repeats.
Last one I wasn't sure on:
RecursiveSeq: The input variable X is an integer between 1 and 50. The function should return as Y the X-th term of a sequence defined recursively by:
f(1) = 1
f(2) = 3
f(X) = 2*f(X-1) 2*f(X-2) for X = 3,4,5,...
Your function code should use recursion (not a loop). Test your function with the following inputs:
X = 2
X = 10
X = 24
X = 33
X = 40
My output:
| x | Output |
| 2 | 3 |
| 10 | 48 |
| 24 | -2048 |
| 33 | 65536 |
| 40 | -524288 |
I'm sure this one could be not to one, but I can't think of an example.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
