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.

542 Appendix BOOK PSEUDOCODE<br />

Because of this relegation of English statements to their own lines, the<br />

interpretation that equation (Y) is to be invoked once, after the pseudoprime<br />

loop, is immediate. Accordingly, when an English statement is sufficiently long<br />

that it wraps around, we have adopted reverse indentation, like so:<br />

Find a random t ∈ [0,p− 1] such that t 2 − a is a quadratic nonresidue<br />

(mod p), via Algorithm 2.3.5;<br />

x =(t + √ t 2 − a) (p+1)/2 ;<br />

...;<br />

In this last example, one continually chooses random integers t in the stated<br />

range until one is found with the required condition, and then one goes to the<br />

next step, which calls for a single calculation and the assignment of letter x<br />

to the result of the calculation.<br />

Also in English will be comments throughout the book pseudocode. These<br />

take the following form (and are right-justified, unlike pseudocode itself):<br />

x =(t + √ t 2 − a) (p+1)/2 ; // Use F p 2 arithmetic.<br />

The point is, a comment prefaced with “//” is not to be executed as<br />

pseudocode. For example, the above comment is given as a helpful hint,<br />

indicating perhaps that to execute the instruction one would first want to have<br />

a subroutine to do F p 2 arithmetic. Other comments clarify the pseudocode’s<br />

nomenclature, or provide further information on how actually to carry out the<br />

executable statement.<br />

Assignment of variables, and conditionals<br />

We have elected not to use the somewhat popular assignment syntax x := y,<br />

rather, we set x equal to y via the simple expedient x = y. (Note that in<br />

this notation for assignment used in our pseudocode, the symbol “=” does<br />

not signify a symmetric relation: The assignment x = y is not the same<br />

instruction as the assignment y = x.) Because assignment appears on the face<br />

of it like equality, the conditional equality x == y means we are not assigning,<br />

merely testing whether x and y are equal. (In this case of testing conditional<br />

equality, the symbol “==” is indeed symmetric.) Here are some examples of<br />

our typical assignments:<br />

x =2; // Variable x gets the value 2.<br />

x = y =2; // Both x and y get the value 2.<br />

F = {}; // F becomes the empty set.<br />

(a, b, c) =(3, 4, 5); // Variable a becomes 3, b becomes 4, c becomes 5.<br />

Note the important rule that simultaneous (vector) assignment assumes first<br />

the full evaluation of the vector on the right side of the equation, followed by<br />

the forcing of values on the left-hand side. For example, the assignment<br />

(x, y) =(y 2 , 2x);<br />

means that the right-hand vector is evaluated for all components, then the<br />

left-hand vector is forced in all components. That is, the example is equivalent<br />

to the chain (technically, we assume neither of x, y invokes hidden functions)

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

Saved successfully!

Ooh no, something went wrong!