{VERSION 5 0 "APPLE_PPC_MAC" "5.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 1 }{CSTYLE "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 35 "" 0 1 104 64 92 1 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 256 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 257 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 258 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 259 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 260 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 261 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 262 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 263 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 264 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 265 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 266 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 267 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 268 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 269 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 270 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 271 "" 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-1 435 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 436 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 437 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 438 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 439 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 440 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 441 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 442 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 443 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Heading 1 " -1 3 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 8 4 1 0 1 0 2 2 0 1 }{PSTYLE "Bullet Item" -1 15 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 3 3 1 0 1 0 2 2 15 2 }{PSTYLE "Heading 1" -1 256 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 8 4 1 0 1 0 2 2 0 1 }{PSTYLE "Norma l" -1 257 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Author" -1 258 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 1 2 2 2 1 1 1 1 }3 1 0 0 8 8 1 0 1 0 2 2 0 1 }{PSTYLE "Title" -1 259 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }3 1 0 0 12 12 1 0 1 0 2 2 19 1 }{PSTYLE "Normal" -1 260 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 1 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "" 0 261 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 259 "" 0 "" {TEXT -1 9 "Lecture 3" }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 50 "if ... then ... elif ... then ... else .. . end if;" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 257 "" 0 "" {TEXT 280 49 "Such statements take one of the following forms:" } {TEXT -1 2 "\n\n" }{TEXT 260 2 "if" }{TEXT -1 1 " " }{TEXT 272 18 "boo lean expression" }{TEXT -1 1 " " }{TEXT 261 4 "then" }{TEXT -1 7 " \n \+ " }{TEXT 273 22 "sequence of statements" }}{PARA 257 "" 0 "" {TEXT 276 7 "end if;" }{TEXT 277 1 "\n" }}{PARA 257 "" 0 "" {TEXT -1 38 "--------------------------------------" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 262 2 "if" }{TEXT -1 21 " boolean expr ession " }{TEXT 263 4 "then" }{TEXT -1 27 " \n sequence of statement s\n" }{TEXT 264 4 "else" }}{PARA 0 "" 0 "" {TEXT -1 24 " sequence of s tatements\n" }{TEXT 278 7 "end if;" }{TEXT -1 1 "\n" }}{PARA 0 "" 0 " " {TEXT -1 38 "--------------------------------------" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 265 2 "if" }{TEXT -1 24 " b oolean expression1 " }{TEXT 266 4 "then" }{TEXT -1 27 " \n sequence \+ of statements\n" }{TEXT 267 4 "elif" }{TEXT -1 21 " boolean expression 2 " }{TEXT 268 4 "then" }}{PARA 0 "" 0 "" {TEXT -1 23 " sequence of st atements" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 4 " " }{TEXT 281 6 ". . . " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT 269 4 "elif" }{TEXT -1 21 " boolean expression3 \+ " }{TEXT 270 4 "then" }{TEXT -1 25 "\n sequence of statements\n" } {TEXT 271 4 "else" }{TEXT -1 26 "\n sequence of statements\n" }{TEXT 279 7 "end if;" }}{PARA 0 "" 0 "" {TEXT -1 38 "----------------------- ---------------" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 22 "[In Maple V one used " }{TEXT 406 2 "fi" }{TEXT -1 14 " \+ in place of " }{TEXT 405 8 "end if ." }{TEXT -1 30 " In Maple 6 and 7 one may use " }{TEXT 407 7 "fi, end" }{TEXT -1 4 " or " }{TEXT 408 6 "end if" }{TEXT -1 42 " interchangeably. So if I slip up and use " } {TEXT 409 2 "fi" }{TEXT -1 48 " from time to time you will know what i t means.]" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 3 "By " }{TEXT 259 18 "boolean expression" }{TEXT -1 36 " we mean a st atement that is either " }{TEXT 383 4 "true" }{TEXT -1 4 " or " } {TEXT 384 5 "false" }{TEXT -1 52 ". (Note: Maple's boolean expressions have the value " }{TEXT 385 4 "true" }{TEXT -1 4 " or " }{TEXT 386 5 "false" }{TEXT -1 8 " and not" }{TEXT 388 5 " True" }{TEXT -1 4 " or \+ " }{TEXT 387 5 "False" }{TEXT -1 49 ".) Such statements are usually co nstructed using " }{TEXT 410 18 "<, <=, >, >=, <>. " }{TEXT -1 3 "or \+ " }{TEXT 411 1 "=" }{TEXT -1 46 " together possibly with the logical o perators " }{TEXT 258 12 "and, or, not" }{TEXT -1 8 ". Note " } {XPPEDIT 18 0 "x <> y;" "6#0%\"xG%\"yG" }{TEXT -1 105 " is denoted by \+ x <> y in Maple. Other types of boolean expressions are formed by proc edures which return " }{TEXT 399 4 "true" }{TEXT -1 4 " or " }{TEXT 400 5 "false" }{TEXT -1 17 ". And example is " }{TEXT 401 10 "isprime( n)" }{TEXT -1 43 ". For specific values of n, this is either " }{TEXT 402 4 "true" }{TEXT -1 4 " or " }{TEXT 403 5 "false" }{TEXT -1 3 ". \n " }}{PARA 0 "" 0 "" {TEXT -1 55 "One can test a boolean expression by \+ using the command " }{TEXT 404 5 "evalb" }{TEXT -1 30 " as in the foll owing examples:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 4 "1<2;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "evalb(1<2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "evalb(2< 1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "evalb(z " 0 "" {MPLTEXT 1 0 8 "restart:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "if t > 1 then \n x:=3; \nend if;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 34 "The expre ssion t > 1 is called a " }{TEXT 257 18 "boolean expression" }{TEXT -1 221 ". The problem here is that Maple does not know the value of t so it cannot tell if t > 1 is true or false. This can be fixed by p utting in a value of t as we now do. Note that a print statement is no t needed if we use " }{TEXT 412 7 "end if;" }{TEXT -1 16 " as opposed to " }{TEXT 413 6 "end if" }{TEXT -1 1 ":" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 30 " Try to anticipate the \+ output." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 48 "t:=3:\nif t > 1 \+ then \n x:=2;\n print(x);\nend if:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "t:=3:\nif t > 1 then \n x:=2;\nend if;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "t:=0:\nif t > 1 then \n x:=2; \ne nd if; " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 44 "t:=0:\nif t > 1 then \n x:=2; \nend if;\nx:=3 ; " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 42 "The above can be done with the following:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 50 "t:=0:\ni f t > 1 then \n x:=2; \nelse\n x:=3;\nend if;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 23 "Here we illustrate the " }{TEXT 256 52 "if .. then . . elif .. then else... fi construction." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 183 "f:=proc(y)\n if y <= 1 then \n return 1;\n elif y \+ <= 2 then \n return 2;\n elif y <= 3 then \n return 3;\n elif y <= 4 then \n return 4;\n else \n return infinity;\n end if;\nend pro c:\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 47 "The same thing can be acc omplished as follows:\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 167 "g:=proc(y)\nif y <= 1 then return 1; end if;\nif y <= 2 then return 2 ; end if;\nif y <= 3 then return 3; end if;\nif y <= 4 then return 4; \+ end if; \nreturn infinity; \nend:\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 56 "We check a few values of x to see that f(x) = g(x): The " } {TEXT 362 5 "by .5" }{TEXT -1 34 " in the do loop causes increments " }{TEXT 414 5 "by .5" }{TEXT -1 24 " instead of the default " }{TEXT 415 4 "by 1" }{TEXT -1 1 "." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 108 "for x from 0 to 5 by .5 do \nprint(`If x= ` , x , ` then, f (x) = ` , f(x) , ` g(x) = `, g(x)); \nod;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 154 "Let's try to plot the function f (t) for t from 0 to \+ 5. The first plot fails, however, the second method works. You can se e that we have a step function." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "plot(f(t),t=0..5, 0..5);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "plot(f,0..5,0..5);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 51 "More examples: We create a boolean valued function." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 115 "is_increasing:=proc(a,b,c)\n if (a < b) and (b < c) then \n return true; \n else\n return false;\n e nd if;\nend proc:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 65 "is_inc reasing(1,2,3);\nis_increasing(1,2,1);\nis_increasing(1,1,1);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 55 "Note that we can get these on the \+ same line as follows:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 63 "is _increasing(1,2,3),is_increasing(1,2,1),is_increasing(1,1,1);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 45 "Here's another example of a boolea n function." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 118 "is_composit e:=proc(n)\n if isprime(n) = false then \n return true; \n else \n return false; \n end if;\n end proc:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 35 "is_composite(10);\nis_composite(11);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 24 "Note that the statement " }{MPLTEXT 1 0 19 "isprime(n) = false " }{TEXT -1 34 "may be replaced by the statemen t " }{MPLTEXT 1 0 15 "not(isprime(n))" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 53 "for ... while .. do ... by .. end do, ne xt and break" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 27 "In Maple 6 one may replace " }{TEXT 288 8 "end do " }{TEXT 289 4 "by " }{TEXT 290 2 "o d" }{TEXT 291 6 " or " }{TEXT 292 3 "end" }{TEXT 293 46 ". In Maple \+ V one can only use the short form " }{TEXT 294 2 "od" }{TEXT 295 1 ". " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 26 "We lo ok at some examples: " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 66 "for i to 3 do \n y:=i^2;\n z:=i^3 ;\n sin(y*z);\n evalf(%);\nend do;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 29 "Note that this is the same as" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 73 "for i from 1 to 3 do \n y:=i^2;\n z:=i^3;\n sin(y* z);\n evalf(%);\nend do;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 356 "Not e that the value of the index i is 4 after the above loop for i from 1 to 3 is executed. Each time one goes throught the loop the value of t he index is incremented by 1 and then if the value is less that the up per limit 3 the loop is executed and control is passed to the next sta tement (if there is one). We now see what the value of the variable i \+ is:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "i;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 83 "If we use by 5.5 then the index is increased by 5.5 each time, as in the following:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 49 "for q from -10 to 10 by 5 .5 do\n print(q);\nend do:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 75 "Of \+ course, 5.5 may be replace by any number.\n\nWe now illustrate the use of " }{TEXT 393 5 "break" }{TEXT -1 91 " in a loop. This program will find the smallest integer w between 1 and 100 that satisfies " } {XPPEDIT 18 0 "2^w > 10^6" "6#2*$\"#5\"\"')\"\"#%\"wG" }{TEXT -1 1 ": " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 122 "for w from 1 to 100 do \n if 2^w > 10^6 then\n print(w, 2^w);\n break;\n end if;\nend do;\nprint(`We are finished!`);\nw;\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 10 "Note that " }{TEXT 283 5 "break" }{TEXT -1 64 " means to \+ get out of the loop and go to the statement following " }{TEXT 309 6 " end do" }{TEXT -1 2 ". " }{TEXT 396 3 "If " }{TEXT 395 5 "break" } {TEXT 397 87 " is executed then the value of the index w is the value \+ at the time the loop is exited " }{TEXT -1 58 "Note that the same resu lt is obtained if we leave out the " }{TEXT 333 6 "to 100" }{TEXT -1 19 " on the first line." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 114 "for w from 1 do\n if 2^w > 10^6 then\n print(w, 2^w);\n break; \n end if;\nend do;\nprint(`We are finished!`);\nw;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 95 "Let's write a program to find the product of al l primes less than 100: Try this program with a " }{TEXT 334 9 "semico lon" }{TEXT -1 7 " after " }{TEXT 335 6 "end do" }{TEXT -1 15 " rather than a " }{TEXT 336 5 "colon" }{TEXT -1 44 ". Now see if you can gues s what the command " }{TEXT 398 4 "next" }{TEXT -1 6 " does." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 104 "P:=1:\nfor m from 1 to 100 \+ do\n if isprime(m) = false then \n next; \n end if;\n P:= P * m; \nend do:\nP; " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 10 "Note that " } {TEXT 284 5 "next " }{TEXT -1 38 " means to go to the next value of th e " }{TEXT 363 5 "index" }{TEXT -1 25 " - in the above case the " } {TEXT 364 5 "index" }{TEXT -1 4 " is " }{TEXT 337 1 "m" }{TEXT -1 88 " - if m is not prime. If m is prime then we replace P by the current v alue of P times m." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 76 "\nIn the following example we seek the smallest positive \+ integer n such that " }{XPPEDIT 18 0 "1000 <= n!;" "6#1\"%+5-%*factori alG6#%\"nG" }{TEXT -1 56 ". When we find it we will call it a. Note th at in maple " }{TEXT 285 12 "factorial(n)" }{TEXT -1 5 " and " }{TEXT 286 2 "n!" }{TEXT -1 23 " give the same result." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 88 "for n from 1 to 10 do \n if 1000 <= n! then \+ \n print(n,n!);\n break;\n end if;\nend do:\nn;\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 35 "Another way to do this is by using " }{TEXT 287 32 "while boolean expression do: " }{TEXT 416 66 "The loop is e xecuted untill the boolean expression becomes false. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 64 "q:=0:\nfor n from 1 while q <= 1000 do\n q:= n!;\nend do:\nn,n-1,q;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 338 214 "Note that the value of n at the end of the above loop is 8. W hen a \"while\" loop is exited the index is increment by 1 as we see a bove. However, when break causes us to exit from a loop the index is n ot incremented." }{TEXT -1 69 " \n\nSee what happens if we omit the q: =0; statement at the beginning:\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 48 "for n from 1 while q < 1000 do\n q:= n!;\nend do:" }}}{PARA 0 "" 0 " " {TEXT -1 118 "This is due to the fact that Maple does not know the v alue of q at the first step, so cannot tell if q < 1000 or not." }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 " " {TEXT -1 44 "Old notation for end do, end if and end proc" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 52 "In versions of \+ Maple prior to Maple 6 one used \n\n " }{TEXT 373 2 "od" }{TEXT -1 12 " instead of " }{TEXT 374 6 "end do" }{TEXT -1 1 "\n" }}{PARA 0 "" 0 "" {TEXT -1 3 " " }{TEXT 375 2 "fi" }{TEXT -1 12 " instead of " } {TEXT 376 6 "end fi" }{TEXT -1 5 "\n\n " }{TEXT 377 3 "end" }{TEXT -1 12 " instead of " }{TEXT 378 8 "end proc" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 261 "" 0 "" {TEXT -1 18 "One may still use " }{TEXT 379 6 "od, fi" }{TEXT -1 5 " and " }{TEXT 380 4 "end " }{TEXT -1 141 " in Maple 6 and 7. You may wish to do so since the old way is a little \+ shorter and so far as I know it does not effect the speed of execution ." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 67 "Also in Maple IV one used \", \"\", and \"\"\" instead of %, %%, %%% and \+ " }{TEXT 381 18 "RETURN(expression)" }{TEXT -1 12 " instead of " } {TEXT 382 17 "return expression" }{TEXT -1 88 " in procedures. Maple 6 and 7 still recognizes RETURN(expression) but not \",\"\", and \"\"\" ." }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 25 "for x in L do ... end do;" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 118 "Here is another way to use do loops. Here we specify exactly which va lues of the index we want the loop to go through:" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 54 "for x in [1,3,X,Y, t^2+t+1] do\n print(x,x^2);\nend \+ do:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 41 "[1,2,X,Y,t^2 + t + 1] is a n example of a " }{TEXT 296 5 "list " }{TEXT -1 229 "--- we will say m ore about lists later. You may also use set brackets \{ \} instead of \+ [ ] as in the following example. Be warned, however, that the order \+ in sets is sometimes lost. If order is important use [ ] instead of \+ \{ \}." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 54 "for x in \{1,3,X, Y, t^2+t+1\} do\n print(x,x^2);\nend do:" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 15 "Nested do loops" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 21 "You may need to ha ve " }{TEXT 339 27 "do loops inside of do loops" }{TEXT -1 115 ". Here are some examples. The first allows us to generate all ordered pairs [i,j ] where i and j are in \{1,2,3,4\}:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 80 "for i from 1 to 4 do \n for j from 1 to 4 do\n print([i,j]);\n end do;\nend do;\n" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 108 "Note that if you use (i,j) instea d of [i,j] in the above code the parentheses will not appear in the ou tput." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 72 "The following allows us to generate all 2 element subsets of \{1,2,3,4\}:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 84 "for i from 1 to 4 do\n for j from i+1 to 4 do\n print(\{i,j\});\n end do;\nend do;" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 51 "Of cou rse, we may do other things other than just " }{TEXT 365 12 "print(\{ i,j\})" }{TEXT -1 284 ". We can take i,j and perform various other ope rations. For example, here we form the set of all sums of i and j whe re i < j and put them in a set called S when i + j is a prime number \+ and we count the number of times that i + j is a prime. For this we ne ed a \"counter\". We call it " }{TEXT 297 5 "count" }{TEXT -1 27 ". It could be any variable." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 55 "We set printlevel to 2 so we can see what is going o n. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "printlevel:=2;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 349 "S:=\{\}:\ncount:=0:\nfor i \+ from 1 to 4 do\n for j from i+1 to 4 do\n print(`--------------- --`);\n print(i,j);\n n:=i+j;\n if isprime(n) then\n \+ count:=count+1;\n print(`count = `, count); \n S:=S union \{n\};\n print(`S = `, S); \n end if;\n end do;\nend \+ do;\nprint(`----------`);\nprint(`S = `, S, `count = `,count);" }}} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 198 "Why is c ount = 4, yet S only contains three elements?\n\nLater we will show ho w to get rid of unwanted commas such as the commas in the last output \+ statement S = , \{ 3,5,7\}, count = , 4 by use of the " }{TEXT 417 6 " printf" }{TEXT -1 18 " comma instead of " }{TEXT 418 5 "print" }{TEXT -1 136 ".\n\nWe can have do loops nested three deep as in the followin g example where we form the set of all binary sequences [lists] of len gth 3:" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 146 "N ote that the print statement in the following program has been comment ed out by use of #. Try removing the # and seeing the difference in ou tput." }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 164 "S:=\{\}:\nfor x1 from 0 to 1 do\n for x2 from 0 to \+ 1 do\n for x3 from 0 to 1 do\n #print(x1,x2,x3);\n S:=S unio n \{ [x1,x2,x3] \};\n end do:\n end do:\nend do:\nS;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 198 "We will learn other ways to define this \+ set later. Clearly you would not want to use this method to produce th e set of all 1024 binary sequences of length 10. That would require 10 nested do loops. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}} {SECT 1 {PARA 3 "" 0 "" {TEXT -1 26 "Local and Global Variables" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT 298 15 "L ocal variables" }{TEXT -1 29 " are variables that are used " }{TEXT 340 6 "inside" }{TEXT -1 99 " a procedure. After the procedure is exec uted the local variables revert to their original values. " }{TEXT 299 16 "Global variables" }{TEXT -1 121 " may be changed inside the pr ocedure and the values will be retained after the procedure is over. H ere are some examples:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "re start:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 89 "We first set the value \+ of the four variables x1,x2,y1,y2 to 1 by executing the following:" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "x1:=1:\nx2:=1:\ny1:=1:\ny2: =1:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 89 "Now we difine a simple pro cedure called f: Take a minute to try to guess what it will do:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 109 "f:=proc(n)\n global x1,x2; \n local y1,y2;\n x1:=2:\n x2:=3:\n y1:=5:\n y2:=7:\n return n*x1* x2*y1*y2;\nend proc:\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 29 "Let's s ee what f(11) returns:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "f( 11);\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 36 "It will help to factor \+ this integer:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "ifactor(%) ;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 45 "Now let's see what happened \+ to the variables " }{TEXT 366 14 "x1, x2, y1, y2" }{TEXT -1 1 ":" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "x1,x2, y1,y2;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 150 "You can see that the global variables re tain the changes made inside the procedure f, but the local variables \+ are unchanged by what happened inside f." }{TEXT 389 51 " I recommend \+ using global variables very sparingly " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 118 "Here's anothe simple exa mple. Execute these commands in order. Try to anticipate what the outp ut will be in each case." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 " restart;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 149 "Note that a procedur e may have no input. But to execute it one still needs parentheses. N ote that we use NULL as output. NULL is the empty sequence." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 51 "f2:=proc()\nglobal x;\nx:=2* x;\nreturn NULL;\nend proc:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 51 "f3:=proc()\nglobal x;\nx:=3*x;\nreturn NULL;\nend proc:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "x:=2;" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 5 "f2();" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "x;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "f3();" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "x;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}} {SECT 1 {PARA 3 "" 0 "" {TEXT -1 29 "print vs return in procedures" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 82 "Co nsider carefully the following procedures named g and h: Notice that t he output " }{TEXT 392 5 "seems" }{TEXT -1 60 " to be the same for eac h. However, see below for differences" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 48 "g:=proc(x)\nlocal y;\ny:=2*x;\nprint(y);\nend proc:\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "h:=proc(x)\nlocal y;\ny:=2*x;\nretu rn y;\nend proc:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "g(3);" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "h(3);" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 52 "But note how g misbehaves in the following example s:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "y:=g(3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "2+g(3);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 31 "But h behaves as we would wish:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "y:=h(3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "2+h(3);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 41 "The moral of this section is: DO NOT USE " }{TEXT 390 5 "print" }{TEXT -1 13 " INSTEAD \+ OF " }{TEXT 391 6 "return" }{TEXT -1 31 " WHEN CONSTRUCTING A PROCEDU RE." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 57 "Use of print, debug, undebug and printlevel for debugging" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 56 "Consider the following attempt to construct a procedure \+ " }{TEXT 419 6 "binexp" }{TEXT -1 63 " whose input is n and whose outp ut is the smallest k such that " }{XPPEDIT 18 0 "n <= 2^k;" "6#1%\"nG) \"\"#%\"kG" }{TEXT -1 1 "." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 107 "binexp:=pro c(n)\nlocal k;\nfor k from 1 to 10 do\n if 2^k >= n then\n return \+ k;\n end if;\nend do;\nend proc:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "binexp(10000);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 163 "Note that we get no output for binexp(10000). In this case you ca n no doubt see the problem but let's illustrate a few debugging techni ques to try to find the bug." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 29 "First we set printlevel:=100;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "printlevel:=100;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "binexp(10000);\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 48 "This doesn't help in this case. Next we try the " }{TEXT 424 5 "debug" }{TEXT -1 69 " command after setting the print level back to the default level of 1:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "printlevel:=1:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "debug(binexp):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "b inexp(10000);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 25 "Again not much h elp. Use " }{TEXT 423 7 "undebug" }{TEXT -1 53 " to turn off the debug ger after you are done with it." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "undebug(binexp);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 24 "Now l et's try inserting " }{TEXT 425 5 "print" }{TEXT -1 223 " statements i n the procedure to see what the value of the variables are as the proc edure runs. (In practice you don't have to recopy the procedure to do \+ this. Just insert the statements as you would with any wordprocessor.) " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 197 "binexp:=proc(n)\nlocal k;\nfor k from 1 to 10 do\nprint(`k=`,k);\nprint(`2^k = `,2^k);\nprin t(`n=`, n);\nprint(`---------------------------`);\n if 2^k >= n then \n return k;\n end if;\nend do;\nend proc:" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 14 "binexp(10000);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 87 "Here we see that k only goes up to 10. So we look back an d see that we need to increase" }}{PARA 0 "" 0 "" {TEXT -1 172 "the va lue of 10 in the upper limit of the do loop. When doing this it suffic es to comment out the print statements by inserting # before them as w e now do as we change the " }{TEXT 420 2 "10" }{TEXT -1 4 " to " } {TEXT 421 8 "infinity" }{TEXT -1 37 " -- or we could merely leave out \+ the " }{TEXT 422 5 "to 10" }{TEXT -1 159 " part and we would get equiv alent results. But note that you must be assured that the procedure wo uld eventually return something else it could go on forever." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 207 "binexp:=proc(n)\nlocal k;\n for k from 1 to infinity do\n#print(`k=`,k);\n#print(`2^k = `,2^k);\n# print(`n=`, n);\n#print(`---------------------------`);\n if 2^k >= n then\n return k;\n end if;\nend do;\nend proc:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 17 "Now we try again:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "binexp(10000);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 17 "Let's check this." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 42 "ev alb(2^13 >= 10000), evalb(2^14 >=10000);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 153 "So the procedure seems to be okay. In general we might w ant to check more values of n, but in this case we can see clearly tha t the procedure is correct." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 7 "nam es (" }{TEXT 431 3 "aka" }{TEXT -1 31 " variables) and reserved words. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 11 "In Maple a " }{TEXT 35 4 "name" }{TEXT -1 2 " (" }{TEXT 341 3 "aka " }{TEXT -1 4 ", a " }{TEXT 300 9 "variable " }{TEXT -1 3 "or " } {TEXT 372 13 "variable name" }{TEXT -1 320 ") is usually a letter foll owed by zero or more letters, digits, and underscores, with lowercase \+ and uppercase letters distinct. The maximum length of a name is system dependent. It may even contain spaces if you enclose it in backquotes ` `. [Note that in output the backquotes are not shown.] Here's an ex treme example." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "`this is \+ the name of a variable`:=2;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 35 "`this is the name of a variable`^2;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 88 "If you use underscores where spaces would be you don't ne ed the back quotes, for example" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "this_is_the_name_of_a_variab le:=3;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 9 "But note:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "this is not the name of a variable: =2;" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 15 "" 0 "" {TEXT 427 8 " Keywords" }{TEXT -1 141 " are reserved words that are used in forming \+ Maple statements. These words cannot be used as variable names. There \+ are 11 operator keywords: " }}{PARA 15 "" 0 "" {TEXT 35 8 " and" } {TEXT -1 2 ", " }{TEXT 35 2 "or" }{TEXT -1 2 ", " }{TEXT 35 3 "xor" } {TEXT -1 2 ", " }{TEXT 35 3 "not" }{TEXT -1 2 ", " }{TEXT 35 7 "implie s" }{TEXT -1 2 ", " }{TEXT 35 5 "union" }{TEXT -1 2 ", " }{TEXT 35 9 " intersect" }{TEXT -1 2 ", " }{TEXT 35 6 "subset" }{TEXT -1 2 ", " } {TEXT 35 5 "minus" }{TEXT -1 2 ", " }{TEXT 35 3 "mod" }{TEXT -1 2 ", \+ " }{TEXT 35 8 "assuming" }{TEXT -1 2 ", " }}{PARA 15 "" 0 "" {TEXT -1 81 "plus 35 additional language keywords, for a total of 46 reserved w ords in Maple: " }}{PARA 0 "" 0 "" {TEXT -1 7 " " }{TEXT 426 631 "and assuming break by catch \n de scription do done elif else \n end \+ error export fi finally \n for \+ from global if implies \n in \+ intersect local minus mod \n module \+ next not od option \n options or proc quit read \n return save stop subset then \n to try \+ union use while \n xor \+ " }}{EXCHG {PARA 260 "" 0 "" {TEXT -1 0 "" }}{PARA 260 "" 0 "" {TEXT -1 28 "Be especially wary of using " }{TEXT 428 4 "stop " }{TEXT -1 2 ", " }{TEXT 429 4 "quit" }{TEXT -1 4 " or " }{TEXT 430 4 "done" }{TEXT -1 76 ". This may cause Maple to quit and you may lose any thing you haven't saved!" }}}{PARA 0 "" 0 "" {TEXT -1 22 " \+ " }}{PARA 0 "" 0 "" {TEXT -1 51 "You may find them at a ny time by using the command " }{MPLTEXT 1 0 9 "?reserved" }{TEXT -1 19 " . Note that since " }{TEXT 301 2 "in" }{TEXT -1 73 " is reserved \+ it cannot be used as a variable. But `in` can be a variable." }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "in:=2;" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 8 "`in`:=2;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "`in`^2;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 58 "But quit even w ith backquotes will not work as a variable." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "`quit`:=3;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 34 "A name cannot begin with a number." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "1x:=2;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 17 "Indexed varia bles" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 68 "We can use indexed variables to create subscripted varibles suc h as " }{XPPEDIT 18 0 "x[1],x[2],x[3],x[4];" "6&&%\"xG6#\"\"\"&F$6#\" \"#&F$6#\"\"$&F$6#\"\"%" }{TEXT -1 13 ". Here's how:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "x[1], x[2], x[3], x[4];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 49 "Such variables can be used as ordinary variables." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "x[1]:=2; x[3]:=x[1]*x[2];" } }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 24 "Here's another example:\n" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 131 "We count the number of times each digit appears in an integer. We first generate a large positive integ er. Execute this assignment." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "N:=2^100-1;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 25 "Now we set u p a variable " }{XPPEDIT 18 0 "c[i];" "6#&%\"cG6#%\"iG" }{TEXT -1 18 " for each integer " }{XPPEDIT 18 0 "i;" "6#%\"iG" }{TEXT -1 47 ". This will hold the number of times the digit " }{XPPEDIT 18 0 "i;" "6#%\"i G" }{TEXT -1 56 " appears in N. First we initialize these variables to 0:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "for i from 0 to 9 do c[i]:=0; end do;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 132 "Now we coun t the number of times each digit appears using the following loop. Not e that the least significant digit of N is give by " }{XPPEDIT 18 0 "` mod`(N,10);" "6#-%$modG6$%\"NG\"#5" }{TEXT -1 112 ". Then we can get \+ rid of this digit by subtracting it and then dividing by 10. Usually \+ we would place : after " }{TEXT 432 6 "end do" }{TEXT -1 54 ", but her e we place ; so you can see what's happening." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 69 "N;\nwhile N > 0 do\nk:=N mod 10;\nc[k]:=c[k]+1; \nN:=(N - k)/10; \nend do;\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 50 "N ow let's see what the values of the counters are:" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 77 "2^100-1;\nfor i from 0 to 9 do \nprint(`digi t`,i,`appears`, c[i], `times`);\nod:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}} {SECT 1 {PARA 3 "" 0 "" {TEXT -1 19 "assigned and anames" }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 4 "The " }{TEXT 433 11 "assigned(n)" }{TEXT -1 9 " returns " }{TEXT 434 4 "true" }{TEXT -1 55 " if n has a value other than its own name, and returns " } {TEXT 435 5 "false" }{TEXT -1 65 " otherwise. This will be useful in t he next section. For example:" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "assigned(x );" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "x:=1;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "assigned(x);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 51 "This also works for indexed variables. For example: " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 66 "for i from 1 to 10 do\n if isprime(i) then P[i]:=i; end if;\nend do:\n" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 70 "for i from 1 to 10 do\nif assigned(P[i]) then \+ print(i); end if;\nend do;" }}}{EXCHG {PARA 15 "" 0 "" {TEXT -1 4 "The " }{TEXT 436 8 "anames()" }{TEXT -1 103 " returns an expression seque nce of names that are currently assigned values other than their own n ame. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "anames();" }}} {EXCHG {PARA 0 "" 0 "" {TEXT 437 10 "`isprime/w" }{TEXT -1 6 "` and " }{TEXT 438 7 "isprime" }{TEXT -1 29 " are names assigned by Maple." }} }{EXCHG {PARA 0 "" 0 "" {TEXT -1 79 "If we restart, you can see that t here are no names that are assigned variables." }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "anames();" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 28 "Squares and Sums of Squares." }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 14 "The procedure " }{MPLTEXT 1 0 9 "root(x,n)" }{TEXT -1 184 " (wh en x is real or complex and n is a positive integer) computes the nth \+ root of x. If x is an integer that is a perfect nth power then the nth root is returned; otherwise the power " }{XPPEDIT 18 0 "x^(1/n);" "6 #)%\"xG*&\"\"\"F&%\"nG!\"\"" }{TEXT -1 98 " is returned unevaluated. \+ We can tell if x is a positive integer by use of the boolean function \+ " }{MPLTEXT 1 0 14 "type(x,posint)" }{TEXT -1 86 " which is true if x is a positive integer and false otherwise. Here are some examples:" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "root(8,3); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "root(2,3); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "root(27,3);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 32 "Compare this with the following:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "27^( 1/3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "simplify(%);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "type(27^(1/3),posint);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "type(root(27,3),posint);" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "root(28,3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "type(%,posint);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 11 "The command" }{TEXT 440 5 " root" }{TEXT -1 100 " also works for floating point numbers and complex numbers. Recall tha t I is the square root of -1. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "root(28.0,3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "ro ot(1+2.0*I,3);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 159 "We now define \+ a procedure is_sqr which determines whether or not a positive integer \+ is a square, that is, whether or not it is the square of another int eger:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "is_sqr:=n->type(ro ot(n,2), posint):\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "is_s qr(16);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "is_sqr(17);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 130 "Now we want to determine whether \+ or not the positive integer n is a sum of two positive squares or not. If it is, we want to find " }{TEXT 342 14 "all solutions " }{TEXT -1 17 "to the equations " }{XPPEDIT 18 0 "n = x^2+y^2;" "6#/%\"nG,&*$%\"x G\"\"#\"\"\"*$%\"yGF(F)" }{TEXT -1 41 " where x and y are positive int egers and " }{XPPEDIT 18 0 "x <= y;" "6#1%\"xG%\"yG" }{TEXT -1 28 ". N ote we may assume that " }{XPPEDIT 18 0 "x <= sqrt(n/2);" "6#1%\"xG- %%sqrtG6#*&%\"nG\"\"\"\"\"#!\"\"" }{TEXT -1 0 "" }{TEXT 359 2 " ." } {TEXT -1 38 " [Can you see why? What happens if " }{XPPEDIT 18 0 "s qrt(n/2) < x;" "6#2-%%sqrtG6#*&%\"nG\"\"\"\"\"#!\"\"%\"xG" }{TEXT -1 46 " ?] Here's one way to write such a procedure:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 210 "sumsqrs:=proc(n)\n local x, y, Sols;\n Sol s:=\{\};\n for x from 1 to evalf(sqrt(n/2)) do\n y:= root(n-x^2,2); \n if type(y,posint) then \n Sols:=Sols union \{\{x,y\}\}; \n \+ end if;\n end do;\n return Sols;\nend proc: " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 34 "\nWhat happens if we leave off the " }{TEXT 360 5 "eva lf" }{TEXT -1 21 " in the 4-th line of " }{TEXT 361 7 "sumsqrs" } {TEXT -1 66 "? Remove it and try. Next we illustrate the use of this p rocedure:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "sumsqrs(50);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 50 "We check these two answers. Not e that \{5\} = \{5,5\}." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 " 1^2+7^2, 5^2 + 5^2;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 74 "What would happen in the definition of sumsqrs if you replaced the command" } {MPLTEXT 1 0 21 " Sols union \{\{x,y\}\}; " }{TEXT -1 5 " by " } {MPLTEXT 1 0 17 "Sols union \{x,y\};" }{TEXT -1 1 "?" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 46 "The number of elements in a set S is given by \+ " }{MPLTEXT 1 0 7 "nops(S)" }{TEXT -1 1 "." }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 9 "nops(\{\});" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "nops(\{a,b,c,d\});" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 70 "We us e this to find the number of different solutions to the equation " } {XPPEDIT 18 0 "n = x^2+y^2" "6#/%\"nG,&*$%\"xG\"\"#\"\"\"*$%\"yGF(F)" }{TEXT -1 28 " where x and y are integers " }{XPPEDIT 18 0 "x <= y;" " 6#1%\"xG%\"yG" }{TEXT -1 14 ". For example:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "nops(sumsqrs(50)) ;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 36 "Let's find the smallest n fo r which " }{XPPEDIT 18 0 "n = x^2+y^2;" "6#/%\"nG,&*$%\"xG\"\"#\"\"\"* $%\"yGF(F)" }{TEXT -1 36 " has at least 2 different solutions:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 100 "for n from 1 do \nif nops(s umsqrs(n)) >= 2 then \n print(n,sumsqrs(n));\n break; \n end if; \nend do;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 36 "Let's find the small est n for which " }{XPPEDIT 18 0 "n = x^2+y^2;" "6#/%\"nG,&*$%\"xG\"\" #\"\"\"*$%\"yGF(F)" }{TEXT -1 36 " has at least 3 different solutions: " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 102 "for n from 1 do \n if nops(sumsqrs(n)) >= 3 then \n print(n,sumsqrs(n));\n break; \n e nd if;\nend do;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 92 "Here's a much more e fficient program due to Robert Israel for the determination of integer s " }{XPPEDIT 18 0 "n <= 20^2+20^2;" "6#1%\"nG,&*$\"#?\"\"#\"\"\"*$F'F (F)" }{TEXT -1 135 " that can be expressed as the sum of two squares i n more than two ways:\n\nNote the use of the subscripted variable T[m] and the command " }{TEXT 439 8 "assigned" }{TEXT -1 140 " which tells us whether or not something has already been assigned to the variabl e T[m]. Note that this will cover all integers from 1 to " }{XPPEDIT 18 0 "1800 = 30^2+30^2;" "6#/\"%+=,&*$\"#I\"\"#\"\"\"*$F'F(F)" }{TEXT -1 1 "." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 189 "restart:\nfor i from 1 to 30 do\n for j from 1 to i do\n m:= i^2 + j^2;\n \+ if assigned(T[m]) then \n T[m]:= T[m],[i,j];\n els e T[m]:= [i,j]\n fi\n od \n od:" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 23 "Here are some examples:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "T[1];\nT[13];\nT[50];\nT[325];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 78 "We can get the number of solutions for, say, T[325], by the following command:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "nops([T[325]]);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 39 "Using this we see which integers up to " }{XPPEDIT 18 0 "2*30^2;" "6#*&\"\"#\"\" \"*$\"#IF$F%" }{TEXT -1 68 " can be express as a sum of square in thre e or more different ways: " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 73 "for m from 1 to 2*30^2 do\nif nops([T[m]]) >=3 then print(m,T[m]); fi;\nod;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 38 "Assignment \+ 3 (Due Monday, February 4)" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT 343 429 "Perhaps you have heard the famous stor y about Ramanujan and Hardy's taxi number: Once when Ramanujan was ill in London, Hardy visited Ramanujan in the hospital. When Hardy remark ed that he had taken taxi number 1729, a singularly unexceptional numb er, Ramanujan immediately responded that this number was actually quit e remarkable: it is the smallest positive integer that can be represen ted in two ways by the sum of two cubes." }{TEXT -1 2 " [" }{TEXT 311 55 "Eric Weisstein's Treasure Trove of Scientific Biography" }{TEXT -1 1 "]" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 310 10 "Problem 1." }{TEXT -1 379 " \n\n(a) Verify (using Maple) Ramanuja n's statement that 1729 is the smallest positive integer that can be e xpressed in two different ways as a sum of two cubes. You should be ab le to use the ideas in the section above on perfect squares and sums o f squares. Only here we are talking of cubes instead of squares. But \+ there are other ways to do the problem that may occur to you. " }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 85 "(b) Find \+ the next number after 1729 that is a sum of two cubes in two different ways." }}{PARA 0 "" 0 "" {TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 1 "\n" }}{PARA 0 "" 0 "" {TEXT -1 0 "" } {TEXT 303 11 "Problem 2. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT 323 11 "Definition." }{TEXT 344 25 " A positive integer n is " }{TEXT 322 7 "perfect" }{TEXT 345 49 " if the sum of its proper \+ positive divisors is n." }{TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 287 "\nFor example, the proper positive divisors of 6 are 1, 2, and 3. Further 6 = 1 + 2 + 3. So 6 is perfect. [If you have had number theor y you may know about the structure of evenperfect numbers. Do not use \+ that knowledge for this exercise. Use only the definition to write yo ur programs.]" }}{PARA 0 "" 0 "" {TEXT 321 6 " \n(a) " }{TEXT -1 108 " Write a procedure which takes as input a positive integer n and return s the sum of all proper divisors of n." }{TEXT 308 1 " " }{TEXT -1 81 "Show how your procedure works for the following values of n: 2, 3, 4, 6, 30, 900." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 302 4 "(b) " }{TEXT 312 34 "Using the procedure you wrote in " } {TEXT 346 3 "(a)" }{TEXT 347 1 " " }{TEXT -1 18 "write a procedure " } {TEXT 348 9 "isperfect" }{TEXT -1 55 " which takes as input a positive integer n and returns " }{TEXT 306 4 "true" }{TEXT -1 21 " if n is pe rfect and " }{TEXT 307 5 "false" }{TEXT -1 9 " if not. " }{TEXT 304 4 "Note" }{TEXT -1 53 ": proper divisors of n can not be greater than n /2. " }{TEXT 324 46 "Use the procedure to find all perfect numbers " } {XPPEDIT 18 0 "n <= 1000;" "6#1%\"nG\"%+5" }{TEXT 325 2 ". " }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 305 17 "I nteresting Fact:" }{TEXT 349 293 " It is an open question whether or n ot there are any odd perfect numbers. So far no one has found one. In \+ number theory you learn the structure of the even perfect numbers. So \+ far only a finite number of even perfect numbers have been found. But \+ it is suspected that there are infinitely many." }{TEXT -1 1 " " }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 313 11 "Problem 3 ." } {TEXT -1 4 " \n\n" }{TEXT 350 10 "Definition" }{TEXT -1 6 ". The " } {TEXT 316 5 "order" }{TEXT -1 1 " " }{TEXT 327 13 "of an integer" } {TEXT -1 3 " a " }{TEXT 326 17 "modulo an integer" }{TEXT -1 59 " m is defined to be the least positive integer e such that " }{XPPEDIT 18 0 "`mod`(a^e,m) = 1;" "6#/-%$modG6$)%\"aG%\"eG%\"mG\"\"\"" }{TEXT -1 32 ". \n\nWrite a procedure, call it " }{TEXT 314 3 "Ord" }{TEXT -1 12 ", such that " }{TEXT 328 8 "Ord(a,m)" }{TEXT -1 9 " returns " } {TEXT 367 4 "FAIL" }{TEXT -1 46 " if the order does not exist and the \+ order of " }{TEXT 443 10 "a modulo m" }{TEXT -1 18 " if it exists.\n \n" }{TEXT 351 91 "You may use the number theoretic result that the or der of a modulo m exists if and only if " }{TEXT 329 13 "igcd(a,m) = 1 " }{TEXT 352 46 ". Also you may use the fact that the order of " } {TEXT 368 10 "a modulo m" }{TEXT 369 23 " is never greater than " } {TEXT 370 5 "m - 1" }{TEXT 371 24 ". [Note that Maple uses " }{TEXT 330 4 "igcd" }{TEXT 353 49 " for the greatest common divisor of intege rs and " }{TEXT 331 3 "gcd" }{TEXT 354 46 " for greatest common diviso r of polynomials.] " }{TEXT -1 29 "\n\n(a) Check that you obtain: " } {TEXT 315 65 "\n\n Ord(0,11) = FAIL, Ord(2,11) = 10, Ord (4,11) = 5." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 12 "(b) Compute " }{TEXT 442 10 "Ord(a, 15)" }{TEXT -1 20 " for a f rom 0 to 20." }}{PARA 0 "" 0 "" {TEXT 441 1 "\n" }}{PARA 0 "" 0 "" {TEXT 332 11 "Problem 4. " }{TEXT -1 15 "For each prime " }{TEXT 357 1 "p" }{TEXT -1 50 " from 2 to 100 find the smallest positive integer \+ " }{TEXT 356 1 "a" }{TEXT -1 11 " such that " }{TEXT 355 14 "Ord(a,p) \+ = p-1" }{TEXT -1 25 ". Print out a table with " }{TEXT 358 4 "p, a" } {TEXT -1 39 " on each row. \n\n[Such an a is called a " }{TEXT 317 27 "primitive elements modulo p" }{TEXT -1 47 " and plays an important ro le in number theory.]" }}{PARA 0 "" 0 "" {TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT 318 5 "Hint:" }{TEXT -1 82 " You might use a loop for p fro m 2 to 100. If p is not prime then use the command " }{TEXT 319 5 "nex t;" }{TEXT -1 195 " to go to the next value of p. If p is prime then g o into another loop for a from 1 to p - 1 looking for an a which has o rder 1 modulo p. When you find one, print it out and then use the comm and " }{TEXT 320 6 "break;" }{TEXT -1 19 " to leave the loop." }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}}}{MARK "9" 0 }{VIEWOPTS 0 0 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 1 1 2 33 1 1 }