Download Wang 700 A/B
Transcript
I, Section V Decision Commands Another slightly different counter is found in the program which stores O's in the first 100 storage registers. In this example, the counter is constantly increasing until it reaches a value of 100. It also serves to designate the storage register being addressed. ~-MARK PRIME SEARCH 0 o o ST INDIR I + I o o SKIP Y = X SEARCH L---O STOP _ _-' Looping Without a Counter Often there is no way to predetermine exactly the number of times a loop is to be performed. Other criteria have to be used. EXAMPLE In calculating the following sum for X > I 1+ l x2 I + .... + x 20 + _14 + _I6 x x ' for specified accuracy the number of terms to be calculated depends on the value of x. However, it is obvious that each successive term gets smaller and smaller and eventually approaches zero. If 12 digits of accuracy are needed, the calculation can be carried out until the last term gets so small that it does not materially affect the overall sum. This occurs' when the term becomes smaller than 10 - 11 and the overall sum on the 700 no longer changes its value when a term is added to it. To write the program. it is convenient to rewrite the series as S=T o +T 1 +T 2 + .... +TnwhereT o = 1 T,=-'zT o x 5-6