identificationdivision. program-id. primes. * aus Wirth, systematisches Programmieren p. 134 author. "JD". date-written. 11.9.2005. date-compiled. environmentdivision. input-outputsection. file-control. select f assignto file-f status f-status. datadivision. filesection. fd f recordcontains 120 characters datarecordis f-record labelrecordisomitted.
01 f-record.
05 i pic x(8). working-storagesection.
78 n value 100.
77 f-status pic S9(4) comp.
77 nroot pic 9(4) value 10.
77 x pic 9(4).
77 square pic 9(4).
77 i pic 9(4).
77 k pic 9(4).
77 lim pic 9(4).
77 prim.
88 prim-true value 1.
88 prim-false value 0.
77 p pic 9(4) occurs n.
77 v pic 9(4) occurs n. proceduredivision. * find first n prime numbers move 2 to p(1) move 2 to i write f-record move 1 to x lim move 4 to square performvarying i from 2 until i = n performuntil prim-true add 2 to x if square <= x then move square to v(lim) add 1 to lim compute square = p(lim)*p(lim) end-if move 2 to k set prim-true totrue performuntilnot prim-true or (k <= lim) if v(k) < x then add p(k) to v(k) end-if if x not=v(k) thenset prim-true totrueend-if add 1 to k end-perform end-perform move x to p(i) write f-record from x end-perform.
fin. * x(1) ... x(n) sind die Lösungen stoprun. end-program primes.
Messung V0.5
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.