'Subject: Print all prime-numbers in PrimFlgs.bin to PrimTabl.log
'Author : Sjoerd.J.Schaper
'Date   : 07-01-2005
'Code   : QuickBasic, PDS, VBdos, FreeBasic
REM $LANG: "qb"
REM $INCLUDE: 'largeint.bi'
i = LargeInit(0, "")
CLS : tim# = TIMER

g$ = SPACE$(64)
Work g$: Lijst = FREEFILE '           working directory
OPEN g$ + "primtabl.log" FOR OUTPUT AS Lijst

cx = PrimCeil
IF cx = 0 THEN
   g$ = "primelist is empty - first run PrimFlgs.bas"
   PRINT #Lijst, g$: PRINT g$
ELSE
   PRINT : PRINT " Creating prime table..."
   PRINT #Lijst, " pi(x)  : x"
   c = 0: sw = 0
   DO
      c = c + 1: cf = Nxtprm(sw)
      IF cf > cx THEN EXIT DO
      PRINT #Lijst, c; TAB(9); ":"; TAB(10); cf
   LOOP
   PRINT " Done"
END IF

eind:
g$ = STR$(CSNG(TIMER - tim#))
g$ = "Timer:" + g$ + " s"
PRINT #Lijst, : PRINT #Lijst, g$
PRINT : PRINT g$
CLOSE Lijst
CALL Term
SYSTEM

