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 recordcontains120 characters datarecordis f-record labelrecordisomitted. 01 f-record. 05 i pic x(8). working-storagesection. 78 n value100. 77 f-status pic S9(4) comp. 77 nroot pic9(4) value10. 77 x pic9(4). 77 square pic9(4). 77 i pic9(4). 77 k pic9(4). 77 lim pic9(4). 77 prim. 88 prim-true value1. 88 prim-false value0. 77 p pic9(4) occurs n. 77 v pic9(4) occurs n. proceduredivision. * find first n prime numbers move2to p(1) move2to i write f-record move1to x lim move4to square performvarying i from2until i = n performuntil prim-true add2to x if square <= x then move square to v(lim) add1to lim compute square = p(lim)*p(lim) end-if move2to 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 add1to 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 in Prozent
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-06-10)
¤
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.