|
http://mathworld.wolfram.com/RelativelyPrime.html
!'Greatest Common Divisor
SET WINDOW 1,3,0,1.2
SET POINT STYLE 7
FOR M=1 TO 50
FOR N=1 TO 100
PLOT POINTS : N/M,GCD(1,N/M)
NEXT N
NEXT M
!'Relatively Prime
!'DIM M(100,100)
!'SET COLOR MIX(0) 1,1,1
!'SET COLOR MIX(1) 0,0,0
!'SET COLOR MIX(2) 1,1,1
!'SET COLOR MIX(3) 1,1,1
!'SET COLOR MIX(4) 1,1,1
!'SET COLOR MIX(5) 1,1,1
!'SET COLOR MIX(6) 1,1,1
!'SET COLOR MIX(7) 1,1,1
!'FOR Y=1 TO 99
!' FOR X=1 TO 99
!' LET M(X,Y)=MOD(GCD(X,Y),8)
!' 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) !'最大公約数
DO WHILE N<>0
LET T=MOD(M,N)
LET M=N
LET N=T
LOOP
LET GCD=M
END FUNCTION
|
|