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.

Appendix BOOK PSEUDOCODE 543<br />

t = x; //Variable t is temporary here.<br />

x = y 2 ;<br />

y =2t;<br />

and it is quite evident by comparison how visually efficient is the single-line<br />

vector assignment. Note, too, that the composite assignments<br />

and<br />

x = y 2 ;<br />

y =2x;<br />

y =2x;<br />

x = y 2 ;<br />

are both different than the vector assignment, and different from each other.<br />

Because our text adheres to the rule that ordered sequences are symbolized<br />

by parentheses (as in (xn)) while sets use braces (as in {X, a, α}), we assign<br />

sequences, vectors, and so on with a style consistent with the text; e.g.,<br />

v =(0, 1, 0) is an ordered assignment, whereas a set of three polynomials<br />

might be assigned as S = {x 2 +1,x,x 3 − x} and the order is unimportant.<br />

Moreover, S = {x 2 +1,x,x,x 3 − x} is exactly the same assignment, since<br />

set notation does not record multiplicity. Note that the distinction between<br />

sequence and set assignment is important, in view of the liberal use of braces<br />

in modern languages. In the Mathematica language, braces denote “lists” and<br />

these in turn can be manipulated as either vectors (sequences) or sets, with<br />

vector-algebraic (such as matrix-vector) and set-theoretical (such as union,<br />

intersection) operators available. Likewise, the C language allows assignment<br />

of data records via braces, as in “float x[3] = {1.1, 2.2, 3.3};” which would fill<br />

a vector x in ordered fashion. In this latter case, our pseudocode would say<br />

instead x =(1.1, 2.2, 3.3).<br />

The internal conditionals in if() statements often use classical mathematical<br />

notation, but not always. Let us exemplify conditional syntax like so:<br />

if(x == y) task(); // Testing equality of x, y, without changing either.<br />

if(x ≥ y) task(); // Testing whether x is greater than or equal to y.<br />

if(x|y) task(); // Testing whether x divides y.<br />

if(x ≡ y (mod p)) task(); // Testing whether x, y congruent modulo p.<br />

Note that a congruence conditional does not take the form x ≡≡ y (mod p),<br />

because there need not be any confusion with assignment in such cases.<br />

However, it may be possible to have the construction x == y mod p, sinceas<br />

is explained in the text, the notation y mod p refers to the integer y − p ⌊y/p⌋.<br />

Thus, it may be that x is equal to this integer, or it may be that we wish to<br />

assign x this value (in which case we would write x = y mod p).<br />

Another conditional form is the while() statement, exemplified by<br />

while(x = 0) {<br />

task1();<br />

task2();

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

Saved successfully!

Ooh no, something went wrong!