This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: 10 = 4*2 + 2 4 = 2*2 + 0 Modular Inversion Algorithm Pseudocode Input r and n Let s'=0 and s=1 while r>0 do t <--- n n <--- r q <--- [t/n] r <--- t - r*q u <--- s s <-- s' - q*s s' <--- u Output s' STOP EXERCISE (10 points) Write a MAPLE implementation of the Modular Inversion Algorithm. Call your function (or proc) modinv. Include an error statement to test whether r and n are relatively prime. Your function should take the form > modinv := proc(r,n) > > > > > > > > > > > > > > > This should compute the multiplicative inverse of r mod n. Test your function with an example: > modinv(23,171); > Did you get 119? This can be checked using MAPLE's modp function. > modp(1/23,171); 119 > (23*119-1)/171; 16 Note: That 119 is the inverse of 23 mod 171 since 119*23=16*171 + 1. Test your function with at least one more example. > > > >...
View Full Document
This note was uploaded on 06/04/2011 for the course MAS 4202 taught by Professor Boyland during the Spring '10 term at University of Florida.
- Spring '10