|
DataMuseum.dkPresents historical artifacts from the history of: RegneCentralen GIER Computer |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about RegneCentralen GIER Computer Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - download
Length: 39564 (0x9a8c) Description: Bits:30000581 Demon 1E Algol III 28/8-70 Types: 8-hole paper tape Notes: Gier Text, Has10
-1- DEMON-1E Demonstration Program for GIER - ALGOLprogrambegin _____procedure translate to ALGOL III (tast,tasttegn,tegn,skrvtegn, _________skrv,skrvtekst,skrvvr);integer procedure tast,tasttegn,tegn,skrvtegn,skrv,skrvtekst,skrvvr; _______ _________begin integer n; _____ _______integer procedure skrvml(n); _______ _________integer n; _______begin integer i; _____ _______for i:=1 step 1 until n do writechar(0) ___ ____ _____ __end; ___commentDEMON-1E Program DEMON-1E.[ s t o p ] -2- _______begin comment GIER DEMONSTRATION PROGRAM-1E; _____ _______boolean newnim, newmap, newlineq, newprime, newlanu; _______integer linerest, oldrand, type; _______switch TYPE := NIM, MAP, LINEQ, PRIME, LANU, FINISH; ______procedure NEWPAGE; _________begin _____for linerest := linerest - 1 while linerest _ -9 do skrvvr; ___ _____ > __linerest := 62end NEWPAGE; ___procedure LINE; _________begin _____linerest := linerest - 1; skrvvr;if linerest < 0 then NEWPAGE __ ____end LINE; ___procedure SHIFT(n); _________value n; _____integer n; _______if linerest < n then NEWPAGE; __ ____procedure CHECKLINE; _________if tegn = 64 ∨ tegn = 192 then __ ____begin _____linerest := linerest - 1; SHIFT(0)end CHECKLINE; ___integer procedure RANDOM(n); _______ _________value n; _____integer n; _______begin _____real y, MOD; ____MOD := 32768; y := oldrand⨯6859; oldrand := y - MOD⨯entier(y/MOD); RANDOM := 1 + entier(n⨯oldrand/MOD)end RANDOM; ___START: oldrand := 999; linerest := 65;newnim := newmap := newlineq := newprime := newlanu := true; ____skrvtegn(62);comment _______-3- DEMON-1 E ;skrvtekst(|< <GIER DEMONSTRATION PROGRAM 1E The program can be used in 5 different ways: 1. Playing the game: NIM. 2. Printing of random maps. 3. Solution of random linear equations. 4. Calculation of prime numbers. 5. Calculation of large numbers. 6 gives end of program.Please write your initials here:|); >linerest := linerest - 11;begin _____integer i, j, sum; _______sum := tasttegn + tasttegn;for i := 1 step 1 until sum do j := RANDOM(1) ___ ____ _____ __end of advance of random procedure; ___RESTART: LINE; LINE; SHIFT(10);skrvtekst(|<Select program type 1-5 (6 gives program stop): |); < >type := tasttegn; LINE; LINE;go_to TYPE[type]; __ __go_to RESTART; __ __NIM: SHIFT(10);skrvtekst(|<Type 1. Playing the game: NIM|); < >LINE; LINE;begin comment NIM-block; _____ _______boolean longtext, winmessage, wrongmessage, loosemessage, present; _______integer M, G, N, g, n, t, gno, remove, fact, R, boolsum, aritsum, ask, _______GMAX, nmax; longtext := newnim;comment _______-4- DEMON-1 E ;if newnim then __ ____begin _____SHIFT(10);skrvtekst(|< <RULES OF THE GAME NIM The game starts with a random selection of G groups of matches. Each groupcontains a maximum of M matches. The value of M is written as 2∧N - 1, and you |must specify N and G. We shall then alternatingly remove matches from the group s. He who removes the last match (or matches) has won. In each move only one group must be touched, and at least one match must be removed from that group.|); >linerest := linerest - 7end if newnim; ___AGAIN: SHIFT(4); LINE;winmessage := wrongmessage := loose message := false; _____skrvtekst(|<Specify N: |); < >N := tast;if N > 9 then N := 9; __ ____LINE; CHECKLINE;M := 2∧N - 1; |ask := 0;skrvtekst(|<Specify G: |); < >G := tast;if G > 15 then G := 15; __ ____LINE; CHECKLINE; LINE; LINE;begin comment inner NIM-block; _____ _______integer array GROUP[1:G], SUM[1:N], BITS[1:G, 1:N]; _______ _____procedure PRINTGROUPS; _________for g := 1 step 1 until G do skrv(|-ndd|, GROUP[g]); ___ ____ _____ __ < >procedure DISPLAY BITS(g); _________value g; _____integer g; _______begin _____R := GROUP[g]; fact := 2;comment _______-5- DEMON-1E ;for n := 1 step 1 until N do ___ ____ _____ __begin _____present := R _ fact⨯fact | R; : =if present then R := R - fact _ 2; __ ____ :BITS[g,n] := if present then 1 else 0; __ ____ ____fact := fact⨯2end for n ___end DISPLAY BITS; ___procedure FIND SUM; _________begin _____aritsum := 0;for g := 1 step 1 until G do aritsum := aritsum + GROUP[g]; ___ ____ _____ __for n := 1 step 1 until N do ___ ____ _____ __begin _____boolsum := 0;for g := 1 step 1 until G do boolsum := boolsum + BITS[g,n]; ___ ____ _____ __SUM[n] := boolsum - boolsum _ 2⨯2 :end; ___boolsum := 0; fact := 1;for n := 1 step 1 until N do ___ ____ _____ __begin _____boolsum := boolsum + SUM[n]⨯fact; fact := 2⨯factend for n ___end FIND SUM; ___for g := 1 step 1 until G do ___ ____ _____ __begin _____GROUP[g] := RANDOM(M); DISPLAY BITS(g)end for g; ___FIND SUM; SHIFT(4);skrvtekst(|<Here are the groups:|); < >LINE;skrvtekst(|<Group no.: |); < >for g := 1 step 1 until G do skrv(|-ndd|, g); ___ ____ _____ __ < >LINE;skrvtekst(|<Number of matches:|); < >PRINTGROUPS; BB: SHIFT(4);comment _______-6- DEMON-1 E ;skrvtekst(|< <If you wish to make the first move, please write a figure 1 here, otherwisea figure 2: |); >linerest := linerest - 2; t := tasttegn;if t | 1 ∧ t | 2 then go_to BB; __ = = ____ __ __if t = 2 then go_to II; __ ____ __ __GG: SHIFT(4); LINE;skrvtekst(if longtext then __ ____|<Write here the number of the group from which you will remove matches: | < >else |<Choose your group: |); ____ < >CC: gno := tast; CHECKLINE; LINE;if gno < 1 ∨ gno > G then __ ____begin _____skrvtekst(|<Sorry, but the number is too |, if gno < 1 then |<low.| else |<high.|); < > __ ____ < > ____ < >DD: LINE;skrvtekst(|< Try again here: |); < >go_to CC __ __end if out of range; ___if GROUP[gno] = 0 then __ ____begin _____skrvtekst(|<Sorry, but this group is empty.|); < >go_to DD __ __end if empty group; ___remove := GROUP[gno];if remove | 1 then __ = ____begin _____SHIFT(4);skrvtekst(if longtext then __ ____|<And the number of matches you want to remove: | else |<And the number: |); < > ____ < >EE: remove := tast; CHECKLINE; LINE;comment _______-7- DEMON- 1E ;if remove < 1 then __ ____begin _____skrvtekst(|<You must remove some matches. Try again: |); < ____ >go_to EE __ __end; ___if remove > GROUP[gno] then __ ____begin _____skrvtekst(|<There are not so many in the group. You are removing the whole group.|); < __ >LINE; remove := GROUP[gno]end if too many ___end if more than one; ___GROUP[gno] := GROUP[gno] - remove;if longtext then longtext := false; __ ____ _____DISPLAY BITS(gno); FIND SUM;II: if boolsum | 0 then __ = ____begin _____SHIFT(4);if winmessage ∧ -, wrongmessage then __ ____begin _____skrvtegn(29);skrvtekst(|<That was wrong. You cannot win now.|); < >FF: loosemessage := wrongmessage := true; ____skrvtegn(62); LINEend of blunder; ___if loosemessage then __ ____begin _____ask := ask + 1;if ask _ 3⨯3 = ask then __ : ____begin _____SHIFT(4); skrvtekst(|<If you want to give up the game, then write a 1 here: |); < >t := tasttegn; LINE;if t = 1 then go_to ASK FOR MORE __ ____ __ __end if third time; ___comment _______-8- DEMON-1E ;go_to GIERMOVE __ __end; ___skrvtegn(29);skrvtekst(|<You cannot win this game.|); < >go_to FF __ __end if boolsum | 0; ___ =if aritsum = 0 then __ ____begin _____SHIFT(4);skrvtekst(|<You have won. Congratulations.|); < >go_to ASK FOR MORE __ __end if finished; ___if -, winmessage then __ ____begin _____SHIFT(4);winmessage := true; ____skrvtegn(29);skrvtekst(|<If you play correctly, you may win this game.|); < >skrvtegn(62); LINEend if not winmessage; ___GMAX := GROUP[1]; gno := 1;for g := 2 step 1 until G do ___ ____ _____ __begin _____if GROUP[g] > GMAX then __ ____begin _____GMAX := GROUP[g]; gno := gend ___end search of largest group; ___remove := 1; JJ: GROUP[gno] := GROUP[gno] - remove; SHIFT(4);if GROUP[gno] > 0 then __ ____begin _____skrvtekst(|<I now remove|); < >skrv(|-ndd|, remove); < >comment _______-9- DEMO N-1E ;skrvtekst(|< from group no.|) < >end group not empty ___else ____skrvtekst(|<I now remove the entire group no.|); < >skrv(|-ndd|, gno); < >skrvtekst(|<. The groups now contain:|); < >LINE; LINE; PRINTGROUPS; DISPLAY BITS (gno); FIND SUM;if aritsum > 0 then go_to GG; __ ____ __ __SHIFT(4); LINE;skrvtekst(|<You have lost.|); < >ASK FOR MORE: LINE;newnim := false; _____HH: skrvtekst(|< <If you wish to try again, please write a figure 1 here, otherwise a figure 2: |) >; linerest := linerest - 1; t := tasttegn;if t | 1 ∧ t | 2 then go_to HH; __ = = ____ __ __LINE; LINE;go_to if t = 1 then AGAIN else RESTART; __ __ __ ____ ____GIERMOVE: for g := 1 step 1 until G do ___ ____ _____ __begin _____if boolsum = GROUP[g] then __ ____begin _____remove := boolsum; gno := g;go_to JJ __ __end if remove whole group ___end for g; ___for n := N step -1 until 1 do ___ ____ _____ __begin _____if SUM[n] = 1 then __ ____begin _____nmax := n;comment _______-10- DEMON -1E ;go_to KK __ __end hit ___end for n; ___KK: for g := 1 step 1 until G do ___ ____ _____ __begin _____if BITS[g, nmax] = 1 then __ ____begin _____gno := g; remove := 0; fact := 1;for n := 1 step 1 until nmax do ___ ____ _____ __begin _____if SUM[n] = 1 then __ ____remove := remove + (if BITS[gno, n] = 1 then fact else - fact) __ ____ ____; fact := fact⨯2end for n; ___go_to JJ __ __end if hit Bits ___end for g; ___go_to HH __ __end inner NIM-block ___end NIM; ___MAP:begin comment MAP-block; _____ _______boolean red, even; _______integer a, amin, amax, b, bs, fh, fhmin, fhmax, fv, fvmin, fvmax, h, hs, _______k, n, ncon, nmap, p, p2, p3, q, r, r1, r2, s, s1, s2, spr;real d, dmin, e, f, g, j, v; ____SHIFT(10);skrvtekst(|<Type 2. Printing of random maps.|); < >LINE; LINE;if newmap then __ ____begin _____SHIFT(18);comment _______-11- DEMON-1 E ;skrvtekst(|< <The following parameters are used in this program: Typical values: nmap: Number of maps. 1 h: Height of maps. 60 b: Breadth of maps. 80 hs: Height of submap. 15 bs: Breadth of submap. 20 ncon: Number of countries per submap. 1 fh: Horizontal scale factor. 1 - 5 Minimum: fhmin, maximum: fhmax. fv: Vertical scale factor. 1 - 5 Minimum: fvmin, maximum: fvmax. a: Rotation angle. 45 Minimum: amin, maximum: amax. spr: Spread factor: Minimum 1, maximum 10. 1|); >linerest := linerest - 16;newmap := false _____end if newmap; ___LL: LINE; SHIFT(5);skrvtekst(|< <Specify the parameters: nmap h b hs bs ncon fhmin fhmax fvmin fvmax amin amax spr|); >nmap := tast; h := tast; b := tast; hs := tast; bs := tast; ncon := tast; fhmin := tast; fhmax := tast; fvmin := tast; fvmax := tast; amin := tast; amax := tast; spr := tast;r1 := h _ hs; :s1 := b _ bs; :p2 := r1⨯s1⨯ncon; linerest := linerest - 3; LINE;for n := 1 step 1 until nmap do ___ ____ _____ __begin comment inner MAP-block; _____ _______integer array cx, cy, fh, fv[1:p2]; _______ _____array cosv, sinv[1:p2]; _____comment _______-12- DEMON-1 E ; p := 0;for r := 1 step 1 until r1 do ___ ____ _____ __for s := 1 step 1 until s1 do ___ ____ _____ __for q := 1 step 1 until ncon do ___ ____ _____ __begin _____p := p+1;cx[p] := (s-1)⨯bs + bs_2 + (RANDOM(bs) - bs_2)_spr; : : :cy[p] := (r-1)⨯hs + hs_2 + (RANDOM(hs) - hs_2)_spr; : : :fh[p] := fhmin + RANDOM(fhmax-fhmin) - 1;if fh[p] < 1 then fh[p] := 1; __ ____fv[p] := fvmin + RANDOM(fvmax-fvmin) - 1;if fv[p] < 1 then fv[p] := 1; __ ____v := 3.14159265/180⨯(amin + RANDOM(amax-amin)); cosv[p] := cos(v); sinv[p] := sin(v)end for q, s, and r; ___SHIFT(h+3); LINE; skrvtegn(62);red := false; _____for r := 1 step 1 until h do ___ ____ _____ __begin _____for s := 1 step 1 until b do ___ ____ _____ __begin _____dmin := 110 5;for p := 1 step 1 until p2 do ___ ____ _____ __begin _____e := cx[p]; f := cy[p]; g := cosv[p]; j := sinv[p];d := (((e-s)⨯g - (f-r)⨯j)/fv[p])∧2 |+ (((e-s)⨯j + (f-r)⨯g)/fh[p])∧2; |if d < dmin then __ ____begin _____dmin := d; p3 := pend if lower distance ___end for p; ___p3 := p3 - 1;p3 := p3 - p3 _ 35⨯35 + 1; :comment _______-13- DEMON-1 E ;even := p3 = p3 _ 2⨯2; :if p3 > 9 then __ ____p3 := if p3 < 19 then p3 + 39 __ ____else ____if p3 < 28 then p3 + 14 else p3 - 10; __ ____ ____if even _ red then __ = ____begin _____skrvtegn(if red then 62 else 29); __ ____ ____red := -, redend; ___skrvtegn(p3)end for s; ___LINEend for r ___end inner MAP-block; ___LINE; LINE; LINE; SHIFT(4); skrvtegn(62);skrvtekst(|<If you want more maps, then write a 1 here: |); < >r := tasttegn;go_to if r = 1 then LL else RESTART __ __ __ ____ ____end of MAP-block; ___LINEQ:begin comment LINEQ-block; _____ _______integer N, i, j; _______SHIFT(10);skrvtekst(|<Type 3. Solution of random linear equations.|); < >LINE; LINE;if newlineq then __ ____begin _____SHIFT(5);skrvtekst(|< <The program generates and solves a set of N random linear equations. The maximum value of N is 24. Calculation time for N = 20 is 23 sec. in ALGOL and 4 sec. in machine language. Specify N = 0 for stop.|); >linerest := linerest - 4;newlineq := false _____end if newlineq; ___MM: LINE;comment _______-14- DEMON -1E ; SHIFT(4);skrvtekst(|<Specify N: |); < >N := tast; LINE;if N > 24 then N := 24; __ ____if N = 0 then go_to RESTART; __ ____ __ __begin comment inner LINEQ-block; _____ _______array x[1:N], MATRIX[1:N, 1:N + 1]; _____procedure LINEQ1 (N, a, x, NOSOLUTION); _________integer N; _______array a, x; _____label NOSOLUTION; _____begin _____integer p, i, j; _______real M; ____for p := 1 step 1 until N - 1 do ___ ____ _____ __begin _____for i := p + 1 step 1 until N do ___ ____ _____ __begin _____if a[p,p] | 0 then go_to L2; __ = ____ __ __if a[i,p] | 0 then go_to L1; __ = ____ __ __if i < N then go_to L3; __ ____ __ __go_to NOSOLUTION; __ __L1: for j := p step 1 until N + 1 do ___ ____ _____ __begin _____M := a[p,j]; a[p,j] := a[i,j]; a[i,j] := Mend of row exchange; ___go_to L3; __ __L2: if a[i,p] = 0 then go_to L3; __ ____ __ __M := -a[i,p]/a[p,p];for j := p+1 step 1 until N+1 do ___ ____ _____ __a[i,j] := a[i,j] + M⨯a[p,j];L3: end for i; ___end for p; ___if a[N,N] = 0 then go_to NOSOLUTION; __ ____ __ __for p := N step -1 until 1 do ___ ____ _____ __begin _____x[p] := a[p,N+1] := a[p,N+1]/a[p,p];comment _______-15- DEMON-1 E ;if p = 1 then go_to L4; __ ____ __ __for i := p-1 step -1 until 1 do ___ ____ _____ __a[i,N+1] := a[i,N+1] - x[p]⨯a[i,p]end for second p; ___L4: end LINEQ-1; ___NN: for i := 1 step 1 until N do ___ ____ _____ __for j := 1 step 1 until N+1 do ___ ____ _____ __MATRIX[i,j] := RANDOM(30000); LINEQ1(N, MATRIX, x, ERROR);go_to MM; __ __ERROR: SHIFT(4); LINE;skrvtekst(|<Sorry, zero determinant. Here is another example.|); < >LINE;go_to NN __ __end of inner LINEQ-block ___end of LINEQ-block; ___PRIME:begin comment prime block; _____ _______boolean first, last, small; _______integer type, num, num1, fact, count, A, B; _______integer procedure PRIM1(x); _______ _________integer x; _______begin _____integer y; _______A: PRIM1 := x := x + 2; y := 1;for y := y + 2 while y⨯y_x do ___ _____ < __if (x_y)⨯y = x then go_to A __ : ____ __ __end; ___procedure READ(number, text); _________integer number; _______string text; ______begin _____real N; ____PP: SHIFT(4); skrvtekst(text); N := tast; LINE;if N < 1 ∨ N > 536870911 then go_to PP; __ ____ __ __comment _______-16- DEMON-1 E ; number := Nend READ; ___SHIFT(10);skrvtekst(|<Type 4. Calculation of prime numbers.|); < >LINE; LINE;if newprime then __ ____begin _____SHIFT(8);skrvtekst(|< <The program contains two calculation types: 1. Calculation of prime factors in a specified number, N. 2. Calculation of primes in a specified range from A to B. Specify type 3 for stop. Upper limit for numbers is 536870911.|); >linerest := linerest - 5;newprime := false _____end of newprime; ___OO: LINE;READ(type, |<Specify prime calculation type: |); < >if type = 1 then __ ____begin _____READ(num, |<Specify number, N: |); < >num1 := num;first := true; ____last := false; _____if num < 4 then __ ____QQ: begin _____skrvtekst(|<Prime|); < >go_to OO __ __end; ___for fact := 2, 3, PRIM1(fact) while fact⨯fact _ num1 ∧ num > 1 do ___ _____ < __begin _____count := 0;RR: if num_fact⨯fact = num then __ : ____SS: begin _____count := count + 1;num := num_fact; :if first then skrvtekst(|<=|); __ ____ < >if count = 1 then __ ____begin _____if -, first then skrvtekst(|<⨯|); __ ____ < >comment _______-17- DEMON- 1E ;first := false; _____skrv(if fact < 10 then |d| __ ____ < >else if fact < 100 then |dd| ____ __ ____ < >else if fact < 1000 then |ddd| ____ __ ____ < >else if fact < 10000 then |dddd| ____ __ ____ < >else |ddddddddd|, fact) ____ < >end if count = 1; ___go_to if last then OO else RR __ __ __ ____ ____end if divisor; ___if count > 1 then __ ____begin _____skrvtekst(|<∧|); < |>skrv(if count < 10 then |d| else |dd|, count) __ ____ < > ____ < >end if power printing; ___count := 0end for fact; ___if first then go_to QQ; __ ____ __ __last := true; ____fact := num;if num > 1 then go_to SS; __ ____ __ __go_to OO __ __end if type = 1 ___else ____if type = 2 then __ ____begin _____READ(A, |<Specify lower limit, A: |); < >READ(B, |<Specify upper limit, B: |); < >small := B < 10000; count := 0;fact := if small then 10 else 8; __ ____ ____SHIFT(4);if A = 1 then A := 2 __ ____else ____if A > 3 then __ ____begin _____A := A - (if A_2⨯2 = A then 1 else 2); __ : ____ ____UU: A := PRIM1(A)end; ___TT: if count_fact⨯fact = count then LINE; __ : ____count := count + 1;if A_B then skrv(if small then |-ddddd| else |-ddddddddd|, A); __ < ____ __ ____ < > ____ < >comment _______-18- DEMON-1 E ;if A < B then __ ____begin _____if A = 2 then __ ____begin _____A := 3;go_to TT __ __end; ___go_to UU __ __end; ___go_to OO __ __end type = 2 ___else ____go_to RESTART __ __end prime block; ___LANU:begin comment large number calculation block; _____ _______boolean first, out; _______integer M, carry, count, c1, c2, d1, d2, type, N, alimit, asize, nn, a, _______b, D, bsize, m;procedure READ(number, text); _________integer number; _______string text; ______begin _____SHIFT(4); skrvtekst(text); number := tast; LINEend READ; ___procedure ALARM(n); _________value n; _____integer n; _______skrvtekst(|< <ERROR |, if n = 1 then |<1| else |<2|); > __ ____ < > ____ < >procedure MULT(n, A, size); _________value n; _____integer n, size; _______integer array A; _______ _____begin _____carry := 0;comment _______-19- DEMON- 1E ;for count := 0 step 1 until alimit do ___ ____ _____ __begin _____c1 := A[count];c2 := c1_M; :c1 := (c1-c2⨯M)⨯n + carry;carry := c1_M; :c1 := c1 - carry⨯M; c2 := c2⨯n + carry;carry := c2_M; :A[count] := (c2-carry⨯M)⨯M + c1;if count = size then __ ____begin _____if carry = 0 then go_to ex __ ____ __ __else ____if count < alimit then size := size + 1 __ ____else ____ALARM(1)end if count ___end for count; ___ex: end MULT; ___procedure DIV(n, A, size, empty); _________value n; _____integer n, size; _______boolean empty; _______integer array A; _______ _____begin _____first := true; ____carry := 0;for count := size step -1 until 0 do ___ ____ _____ __begin _____c1 := A[count];c2 := c1_M; :c1 := c1 - c2⨯M; carry := carry⨯M + c2;c2 := carry_n; :carry := (carry - c2⨯n)⨯M + c1;c1 := carry_n; :carry := carry - c1⨯n; A[count] := c1 := c1 + c2⨯M;comment _______-20- DEMON- 1E ;if first then __ ____begin _____if c1 > 0 then first := false __ ____ _____else ____if size > 0 then size := size - 1 __ ____end if first ___end for count; ___empty := first ∧ c1 = 0end DIV; ___procedure ADD(plus, A, B, asize, bsize); _________value plus, bsize; _____boolean plus; _______integer asize, bsize; _______integer array A, B; _______ _____begin _____carry := 0;for count := 0 step 1 until alimit do ___ ____ _____ __begin _____c1 := A[count]; d1 := B[count];c2 := c1_M; d2 := d1_M; : :c1 := c1-c2⨯M; d1 := d1 - d2⨯M;c1 := c1 + (if plus then d1 else - d1) + carry; __ ____ ____carry := 0;L1: if c1 < 0 then __ ____begin _____c1 := c1 + M; carry := carry - 1;go_to L1 __ __end if c1 negative; ___d1 := c1_M; :c1 := c1 - d1⨯M;c2 := c2 + (if plus then d2 else - d2) + d1 + carry; __ ____ ____carry := 0;L2: if c2 < 0 then __ ____begin _____c2 := c2 + M; carry := carry - 1;go_to L2 __ __end if c2 negative; ___d1 := c2_M; :comment _______-21- DEMON-1 E ; c2 := c2 - d1⨯M; carry := carry + d1; A[count] := c1 := c1 + c2⨯M;if count _ bsize ∧ carry = 0 then go_to L3 __ > ____ __ __end for count; ___if carry | 0 then ALARM(2); __ = ____L3: first := true; ____for count := alimit step -1 until 0 do ___ ____ _____ __begin _____asize := count;if A[count] | 0 then go_to L4 __ = ____ __ __end; ___L4: end ADD; ___procedure P4(n); _________value n; _____integer n; _______begin _____integer i, z, D, a; _______D := 1000;z := if first then 0 else 16; __ ____ ____for i := 1 step 1 until 4 do ___ ____ _____ __begin _____a := n_D; :n := n - a⨯D;if a | 0 then __ = ____begin _____skrvtegn(a);first := false; _____z := 16end ___else skrvtegn(z); ____D := D_10 :end for i ___end P4; ___procedure PR(A, size); _________value size; _____integer size; _______array A; _____begin _____first := true; ____comment _______-22- DEMON-1 E ; d1 := 0;for count := size step -1 until 0 do ___ ____ _____ __begin _____c1 := A[count];c2 := c1_M; :c1 := c1 - c2⨯M; P4(c2); skrvml(1); P4(c1); skrvml(1); d1 := d1 + 1;if d1_8⨯8 = d1 then LINE __ : ____end for count ___end PR; ___SHIFT(10);skrvtekst(|<Type 5. Calculation of large numbers.|); < >LINE; LINE;if newlanu then __ ____begin _____SHIFT(8);skrvtekst(|< <The program contains four calculation types: 1. Calculation of the factorial: FAC(N) = 1⨯2⨯3⨯4........⨯N.2. Calculation of the power: a∧b. |3. Calculation of e = 2.718...... with D digits. 4. Calculation of pi = 3.1415.... with D digits. 5. gives program stop.|); >linerest := linerest - 7;newlanu := false _____end of newlanu; ___LINE; M := 10000;VV: READ(type, |<Specify large number calculation type: |); < >if type = 1 then __ ____begin _____READ(N, |<Specify N:|); < >if N > 1000 then N := 1000; __ ____alimit := 0.05⨯N⨯ln(N);begin _____integer array FAC[0:alimit]; _______ _____comment _______-23- DEMON- 1E ;for count := 0 step 1 until alimit do FAC[count] := 0; ___ ____ _____ __asize := 0; FAC[0] := 1;for nn := 1 step 1 until N do MULT(nn, FAC, asize); ___ ____ _____ __LINE; LINE; SHIFT(4);skrvtekst(|<FAC :=|); < >LINE; PR(FAC, asize); LINE;go_to VV __ __end block ___end if type = 1 ___else ____if type = 2 then __ ____begin _____READ(a, |<Specify a: |); < >READ(b, |<Specify b: |); < >alimit := 1 + 0.055⨯b⨯ln(a);begin _____integer array POT[0:alimit]; _______ _____for count := 0 step 1 until alimit do POT[count] := 0; ___ ____ _____ __asize := 0; POT[0] := 1;for nn := 1 step 1 until b do MULT(a, POT, asize); ___ ____ _____ __LINE; LINE; SHIFT(4);skrvtekst(|<a∧b := |); < | >LINE; PR(POT, asize); LINE;go_to VV __ __end block ___end if type = 2 ___else ____if type < 5 then __ ____begin _____READ(D, |<Specify D: |); < >alimit := D_8; :comment _______-24- DEMON-1E ;if alimit⨯8 | D then __ = ____begin _____skrvtekst(|<D is changed to:|); < >alimit := alimit + 1; D := 8⨯alimit;skrv(|nddd|, D); < >LINEend; ___D := 8⨯alimitend ___else go_to RESTART; ____ __ __if type = 3 then __ ____begin _____integer array RESULT, TERM[0:alimit]; _______ _____for count := 0 step 1 until alimit do ___ ____ _____ __RESULT[count] := TERM[count] := 0; asize := bsize := alimit; RESULT[alimit] := 2; TERM[alimit] := 1;out := false; _____m := 1;for m := m + 1 while -, out do ___ _____ __begin _____DIV(m, TERM, bsize, out);ADD(true, RESULT, TERM, asize, bsize) ____end for m; ___LINE; LINE; SHIFT(4);skrvtekst(|<e⨯10∧D := |); < | >LINE; PR(RESULT, asize); LINE;go_to VV __ __end block if type = 3 ___else ____begin _____boolean out1, out2, out3, plus; _______integer t1size, t2size, t3size, ssize; _______integer array RESULT, T1, T2, T3, SUM[0:alimit]; _______ _____comment _______-25- DEMON-1 E ;for count := 0 step 1 until alimit do ___ ____ _____ __RESULT[count] := T1[count] := T2[count] := T3[count] := 0; T1[alimit] := T2[alimit] := T3[alimit] := 24; asize := t1size := t2size := t3size := alimit; DIV(8, T1, t1size, out1); DIV(171, T2, t2size, out2); DIV(1434, T3, t3size, out3);plus := false; _____m := -1;for m := m + 2 while -, out1 do ___ _____ __begin _____for count := 0 step 1 until alimit do SUM[count] := 0; ___ ____ _____ __ssize := 0;ADD(true, SUM, T1, ssize, t1size); ____if -, out2 then ADD(true, SUM, T2, ssize, t2size); __ ____ ____if -, out3 then ADD(true, SUM, T3, ssize, t3size); __ ____ ____DIV(m, SUM, ssize, out); plus := -, plus; ADD(plus, RESULT, SUM, asize, ssize); DIV(64, T1, t1size, out1);if -, out2 then DIV(3249, T2, t2size, out2); __ ____if -, out3 then for nn := 1,2 do DIV(239, T3, t3size, out3) __ ____ ___ __end for m; ___LINE; LINE; SHIFT(4);skrvtekst(|<pi⨯10∧D :=|); < | >LINE; PR(RESULT, asize); LINE;go_to VV __ __end type = 4 ___end LANU-block; ___FINISH:end of program DEMON-1E; ___[ e n d ] [ s t o p ] comment _______-26- DEMON-1E ; translate to ALGOL III (typein,typechar,char,writechar,write, writetext,writecr);end; ___Jørgen Kjær[ s t o p ] 8