CALL XGETINFO ;
TOUT = XFIXS("\mnt\home\TOUT.TXT") ;
;
CALL XFDEL TOUT ;
NUMERIC DIGITS 50 ;
CALL XCLS ;
DO XCNT = 3 TO 3
CALL NTH XCNT 1000 ;
END
CALL PRIMES 12999999 ;Regina can do this many
;Change to lower number till your rexx fails
TR = LINEOUT(TOUT) ;
EXIT
POWER: PROCEDURE
ARG X,Y
POW = X**Y
RETURN POW
ISPERFECT: PROCEDURE
ARG N
RETURN 0
ISPRIME: PROCEDURE
ARG LASTNO
IF LASTNO = 2 THEN RETURN 1
PRIME. = 1
DO N = 3 TO LASTNO BY 2
IF PRIME.N THEN DO
IF N = LASTNO THEN RETURN 1
DO K = N TO LASTNO BY N+N
PRIME.K = 0
END
END
END
RETURN 0
PRIMES: PROCEDURE EXPOSE TSPF TOUT
ARG LASTNO
STIME = TIME('E') ;
DCNT. = 0
CNT = 0
T = 0
CALL FSAY "+=======================================================+"
CALL FSAY "Recap - Solved for Primes Under "LASTNO" - Using "TSPF
CALL FSAY '2 IS A PRIME NUMBER'
PRIME. = 1
DO N = 3 TO LASTNO BY 2
IF PRIME.N THEN DO
CALL FSAY N 'IS PRIME'
T = RIGHT(N,1);DCNT.T = DCNT.T + 1;DCNT.10 = DCNT.10 + 1
DO K = N TO LASTNO BY N+N
PRIME.K = 0
END
END
END
ETIME = TIME('E') ;
;
CALL FSAY " "
CALL FSAY " Elapsed Time = "ETIME" Seconds"
CALL FSAY " "
CALL FSAY DCNT.10" Total Primes Generated"
DO CNT = 0 TO 9
T = (DCNT.CNT / DCNT.10) * 100
CALL FSAY FORMAT(CNT,6,0)" "FORMAT(DCNT.CNT,15,0)" "FORMAT(T,4,0)"%"
END
RETURN
NTH: PROCEDURE EXPOSE TSPF TOUT
ARG XCNT NCNT
BCNT. = 0 ;
CNT = 0 ;
CALL FSAY "+=======================================================+"
CALL FSAY "Recap - Solved "NCNT" Iterations fo X^ "XCNT" - Using "TSPF
;
STIME = TIME('E') ;
;
DO CNT = 1 TO NCNT
CCNT = CNT; DO (XCNT-1); CCNT = CCNT * CNT; END
LCNT = LENGTH(CCNT) ;
SCNT = 0 ;
;
DO TCNT = 1 TO LCNT
SCNT = SCNT + SUBSTR(CCNT,TCNT,1) ;
END
;
IF CNT = SCNT THEN DO
CALL FSAY "Bingo "CNT"="CCNT" "SCNT
BCNT.0 = BCNT.0 + 1 ;
END
;
IF CNT <> SCNT THEN DO
BCNT.SCNT = BCNT.SCNT + 1 ;
END
END
;
ETIME = TIME('E') ;
;
CALL FSAY " Elapsed Time = "ETIME" Seconds"
CALL FSAY " "
CALL FSAY " Number Occured Percentage"
;
DO CNT = 0 TO 1000
OP = 0 ;
IF BCNT.CNT = 0 THEN
NOP
ELSE DO
OP = ((BCNT.CNT / NCNT) * 100) ;
CALL FSAY FORMAT(CNT,10,0)" "FORMAT(BCNT.CNT,10,0)" "FORMAT(OP,3,0)"%"
END
END
RETURN
FSAY: PROCEDURE EXPOSE TOUT TSPF
PARSE ARG FVAR ;
SAY FVAR ;
TR = LINEOUT(TOUT,FVAR) ;
RETURN
XDETREXX: PROCEDURE
parse version name level date1 date2 date3
parse source S1
TOS = TRANSLATE(WORD(S1,1))
TSPF = 0 ;
IF name = "REXXSAA" & date3 = "1994" THEN TSPF = '0 ' ;
IF name = "REXX-r4" THEN TSPF = '1 ' ;
IF name = "REXXPC88" & date3 = "1987" THEN TSPF = '2 ' ;
IF name = "REXX/Personal" & date3 = "1992" THEN TSPF = '3 ' ;
IF name = "REXX/2" & date3 = "1995" THEN TSPF = '4 ' ;
IF name = "REXX/2" & date3 = "1996" THEN TSPF = '5 ' ;
IF LEFT(name,11) = "REXX-ooRexx" THEN TSPF = '6 ' ;
IF LEFT(name,11) = "REXX-Regina" THEN TSPF = '7 ' ;
IF name = "REXX" & date3 = "99" THEN TSPF = '8 ' ;
IF name = "brexx" & date3 = "2003" THEN TSPF = '9 ' ;
IF LEFT(name,11) = "REXX:Open-R" THEN TSPF = '10 ';
IF LEFT(name,11) = "REXX-ooRexx" & TOS = "LINUX" THEN TSPF = '11 ' ;
IF LEFT(name,15) = "REXX-Regina_3.6" & TOS = "UNIX" THEN TSPF = '12 ' ;
TSPF = TSPF' 'TOS' 'name
TSPF = TSPF" "S1" "ADDRESS()
RETURN (TSPF)
XCMD: PROCEDURE
PARSE ARG TCMD
TSPF = WORD(XDETREXX(),1) ;
IF TSPF = 0 THEN ADDRESS COMMAND TCMD ;
IF TSPF = 1 THEN TCMD ;
IF TSPF = 2 THEN ADDRESS DOS TCMD ;
IF TSPF = 3 THEN ADDRESS SYSTEM TCMD ;
IF TSPF = 4 THEN ADDRESS DOS TCMD ;
IF TSPF = 5 THEN ADDRESS DOS TCMD ;
IF TSPF = 6 THEN TCMD ;
IF TSPF = 7 THEN TCMD ;
IF TSPF = 8 THEN ADDRESS SYSTEM ;
IF TSPF = 9 THEN ADDRESS SYSTEM ;
IF TSPF = 10 THEN CMD TCMD ;
IF TSPF = 11 THEN TCMD ;
IF TSPF = 12 THEN TCMD ;
RETURN
XGETINFO:
TREXX = XDETREXX() ;
TSPF = WORD(TREXX,1) ;
TOS = WORD(TREXX,2) ;
RETURN
XCLS: PROCEDURE EXPOSE TSPF
IF (TSPF = 11 | TSPF = 12) THEN
CALL XCMD "clear"
ELSE
CALL XCMD "CLS"
RETURN
XFIXS: PROCEDURE EXPOSE TSPF
PARSE ARG TS
IF (TSPF = 11 | TSPF = 12) THEN
TS = TRANSLATE(TS,"/","\") ;
ELSE
TS = TRANSLATE(TS,"\","/") ;
RETURN TS
XFDEL: PROCEDURE EXPOSE TSPF
PARSE ARG TOUT
IF (TSPF = 11 | TSPF = 12) THEN
TCMD = "rm "TOUT ;
ELSE
TCMD ="DEL "TOUT ;
CALL XCMD TCMD
RETURN