In: Computer Science
1. Use the Extended Euclid's Algorithm to solve ƒ-1 for 8 mod 11
2. Use the max function to calculate max3(x, y, z) if x = 2, y = 6, z = 5. Show your work!
1. First lets apply the algorithm. It will verify that gcd(8,11) = 1.
11 = 8(1) + 3
8 = 3(2) + 2
3 = 2(1) + 1
2 = 1(2)
Now solve for remainders,
3 = 11 - 8(1)
2 = 8 - 3(2)
1 = 3 - 2(1)
Now reverse the process using these equations,
1 = 3 - 2(1)
1 = 3 - (8 - 3(2)) (1)
1 = 3 - (8 - (3(2))
1 = 3(3) - 8
1 = (11 - 8(1) )(3) - 8
1 = 11(3) - 8(4)
1 = 11(3) + 8(-4)
Therefore 1 ≡ 8(−4) mod 11, or if you want to prefer a residue value for f-1,
1 ≡ 8(7) mod 11.
2. As the programming language is not mentioned so I am doing it in C++. Let's define a max3(x,y,z) function which will calculate the maximum of 3 values.
int max3(int x, int y, int z)
{
int largest = x;
if(largest < y)
largest = y;
if(largest < z)
largest = z;
else
return largest.
}
This function will find the largest of three numbers.
If you want to use the by-default function max(), you can prefer Python language as it simply provides a by-default function to calculate the largest of the given numbers.
If you still have any doubt/query regarding the solution then let me know in comment. If it helps, kindly give an upVote to this answer.