10.12.2012 Views

Prime Numbers

Prime Numbers

Prime Numbers

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

9.2 Enhancements to modular arithmetic 451<br />

The reason for the particular power in the definition is to allow our<br />

eventual general div algorithm to function. Next, we give a method for rapid<br />

computation of R(N), based on multiplies, adds, and subtracts alone:<br />

Algorithm 9.2.8 (Generalized reciprocation). This algorithm returns R(N)<br />

for positive integer N.<br />

1. [Initialize]<br />

b = B(N − 1); r =2 b ; s = r;<br />

2. [Perform discrete Newton iteration]<br />

r =2r −⌊N⌊r 2 /2 b ⌋/2 b ⌋;<br />

if(r ≤ s) goto [Adjust result];<br />

s = r;<br />

goto [Perform discrete Newton iteration];<br />

3. [Adjust result]<br />

y =4 b − Nr;<br />

while(y

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!