figure;
N = 34;%364;

IntegersX = [];
IntegersY = [];
figure;
if mod(N/4,1) < 0.001,
    Set = 1:N/2;
else
    Set = 0:N/2;
end
Set = 0:N/2;
for i=Set,
    
    Xs = 1:1:(N/2)+i;
    Ys = ((N/2)-i)./Xs;
    Diffs = Ys(1:length(Ys) - 1) ./ (Ys(1:length(Ys) - 1) - Ys(2:length(Ys)));
    XsPos = 1:1:N;
    YsPos =((N/2)+i)./XsPos;
    if isprime(N/2 - i) && isprime(N/2 + i) && (N/2 - i)~=2 && (N/2 + i)~=2,
        plot(XsPos,YsPos,'g-');hold on;
        plot(Xs,Ys,'g-');hold on;
        plot(XsPos,N-YsPos,'g-');hold on;
        plot(Xs,N-Ys,'g-');hold on;
        plot(1 + N/2 - XsPos,YsPos,'g-');hold on;
        plot(1 + N/2 - Xs,Ys,'g-');hold on;
        plot(1 + N/2 - XsPos,N-YsPos,'g-');hold on;
        plot(1 + N/2 - Xs,N-Ys,'g-');hold on;
        N/2 - i,
        N/2 + i,
    else
        plot(XsPos,YsPos,'b-');hold on;
        plot(Xs,Ys,'b-');hold on;
        plot(XsPos,N-YsPos,'b-');hold on;
        plot(Xs,N-Ys,'b-');hold on;
        plot(1 + N/2 - XsPos,YsPos,'b-');hold on;
        plot(1 + N/2 - Xs,Ys,'b-');hold on;
        plot(1 + N/2 - XsPos,N-YsPos,'b-');hold on;
        plot(1 + N/2 - Xs,N-Ys,'b-');hold on;
    end
    RotYsPos = N-YsPos;
    RotYs = N-Ys;
    InvertedXs = 1 + N/2 - XsPos;
    
    IntXTemp = [Xs(mod(Ys,1) < 0.001) XsPos(mod(YsPos,1) < 0.001) Xs(mod(RotYs,1) < 0.001) XsPos(mod(RotYsPos,1) < 0.001) InvertedXs(mod(RotYsPos,1) < 0.001) InvertedXs(mod(RotYs,1) < 0.001) InvertedXs(mod(YsPos,1) < 0.001) InvertedXs(mod(Ys,1) < 0.001)];
    IntYTemp = [Ys(mod(Ys,1) < 0.001) YsPos(mod(YsPos,1) < 0.001) RotYs(mod(RotYs,1) < 0.001) RotYsPos(mod(RotYsPos,1) < 0.001) RotYsPos(mod(RotYsPos,1) < 0.001) RotYs(mod(RotYs,1) < 0.001) YsPos(mod(YsPos,1) < 0.001) Ys(mod(Ys,1) < 0.001)];
    IntegersX(end + 1:end + length(IntXTemp)) = IntXTemp;
    IntegersY(end + 1:end + length(IntYTemp)) = IntYTemp;
    plot(IntegersX,IntegersY,'Marker','o','MarkerFaceColor','r','LineStyle','none');
    GridIntegersX = [];
    GridIntegersY = [];
    for i=1:floor(sqrt(N)),
       for j=1:floor(sqrt(N)),
        GridIntegersX(end + 1) = i;
        GridIntegersY(end + 1) = j;
       end
    end
    plot(GridIntegersX,GridIntegersY,'Marker','o','MarkerEdgeColor','r');
    plot([0 N], [0 N],'g-');
    plot([0 N], [N 0],'g-');
set(gca,'XLim',[0 sqrt(N)],'YLim',[0 sqrt(N)]);
end
plot([0 N], [0 N],'g-');
set(gca,'XLim',[0 N],'YLim',[0 N]);