Pythagorean Triple

 投稿者:しばっち  投稿日:2015年10月28日(水)22時22分50秒
 
!'Pythagorean Triple
CALL GINIT(600,600)
SET WINDOW -200,200,-200,200
FOR X=0 TO 200
   FOR Y=0 TO 200
   !' IF X>=Y AND FRAC(SQR(X*X-Y*Y))=0 THEN
      IF FRAC(SQR(X*X+Y*Y))=0 THEN
         CALL PSET(X,Y,7)
         CALL PSET(-X,Y,7)
         CALL PSET(X,-Y,7)
         CALL PSET(-X,-Y,7)
      END IF
   NEXT  Y
NEXT   X
END

EXTERNAL SUB PSET(X,Y,C)
SET POINT COLOR C
PLOT POINTS:X,Y
END SUB

EXTERNAL SUB GINIT(XSIZE,YSIZE)
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

EXTERNAL  FUNCTION FRAC(Z)
LET FRAC=Z-INT(Z)
END FUNCTION
 

戻る