Question: 2 Task Two. Square and Multiply - Fast Exponentiation (2 marks) You are to implement fast.cpp or fast.java in this task, to implement the fast

2 Task Two. Square and Multiply - Fast Exponentiation (2 marks) You are to implement fast.cpp or fast.java in this task, to implement the fast exponentiation using the square and multiply technique as described in the lecture. That is, you need to compute: a (mod p) Your program needs to input three parameters, namely a, b and p. Then, you will need to do the following: Convert b into binary. Convert that binary to the S and X notation. Remove the first SX. Compute according to the sequence. The program must output each process one by one to the screen - not directly outputting the final result only. The number of steps must match the sequence of SX as identified above. Your implementation must be able to produce result (output) where the value of b is greater than 256 or a number that is at least 8 bits long. 2 Task Two. Square and Multiply - Fast Exponentiation (2 marks) You are to implement fast.cpp or fast.java in this task, to implement the fast exponentiation using the square and multiply technique as described in the lecture. That is, you need to compute: a (mod p) Your program needs to input three parameters, namely a, b and p. Then, you will need to do the following: Convert b into binary. Convert that binary to the S and X notation. Remove the first SX. Compute according to the sequence. The program must output each process one by one to the screen - not directly outputting the final result only. The number of steps must match the sequence of SX as identified above. Your implementation must be able to produce result (output) where the value of b is greater than 256 or a number that is at least 8 bits long
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
