|
!'Irreducible Fraction
OPTION ARITHMETIC COMPLEX
LET R=30
DIM M(-R TO R,-R TO R)
FOR Y=1 TO R
FOR X=1 TO R
IF GCD(X,Y)=1 AND ISPRIME(COMPLEX(X,Y))<>0 THEN
LET M(X,Y)=1
LET M(-X,Y)=1
LET M(X,-Y)=1
LET M(-X,-Y)=1
END IF
NEXT X
NEXT Y
SET WINDOW 0,1,1,0
MAT PLOT CELLS, IN 0 , 0 ; 1,1 : M
END
EXTERNAL FUNCTION GCD(M,N) !'最大公約数
OPTION ARITHMETIC COMPLEX
DO WHILE N<>0
LET T=MOD(M,N)
LET M=N
LET N=T
LOOP
LET GCD=M
END FUNCTION
EXTERNAL FUNCTION ISPRIME(Z)
OPTION ARITHMETIC COMPLEX
FOR I=1 TO INT(SQR(RE(Z)))
FOR J=1 TO INT(SQR(IM(Z)))
LET ZZ=Z/COMPLEX(I,J)
IF FRAC(RE(ZZ))=0 AND FRAC(IM(ZZ))=0 THEN
LET ISPRIME=0
EXIT FUNCTION
END IF
NEXT J
NEXT I
LET ISPRIME=1
END FUNCTION
EXTERNAL FUNCTION FRAC(Z)
OPTION ARITHMETIC COMPLEX
LET FRAC=Z-INT(Z)
END FUNCTION
EXTERNAL SUB GINIT(XSIZE,YSIZE)
OPTION ARITHMETIC COMPLEX
SET BITMAP SIZE XSIZE,YSIZE
SET WINDOW 0,XSIZE-1,YSIZE-1,0
SET POINT STYLE 1
SET COLOR MODE "REGULAR"
SET COLOR MIX(0) 0,0,0
SET COLOR MIX(1) 0,0,1
SET COLOR MIX(2) 1,0,0
SET COLOR MIX(3) 1,0,1
SET COLOR MIX(4) 0,1,0
SET COLOR MIX(5) 0,1,1
SET COLOR MIX(6) 1,1,0
SET COLOR MIX(7) 1,1,1
CLEAR
END SUB
|
|