File:Euclid's Orchard.svg

Summary

Description
English: Slice of one corner of Euclid's Orchard
Date
Source Own work
Author Glosser.ca
SVG development
InfoField
Source code
InfoField

Asymptote code

int gcd(int a, int b) {
    int t;
    while(b > 0) {
        t = a;
        a = b;
        b = t % b;
    }

    return a < 0 ? -a : a;
}

size(10cm,10cm);

int ndots = 6;
draw((0,0)--(ndots - 0.5,0),Arrow);
draw((0,0)--(0,ndots - 0.5),Arrow);

for(int i = 1; i < ndots; ++i) {
    for(int j = 1; j < ndots; ++j) {
        //Loop needed to ensure lines go behind all other objects
        pair tree = (i, j);
        if (gcd(i,j) == 1 ) {
            draw((0,0)--tree,dotted);
        }
    }
}

for(int i = 1; i < ndots; ++i) {
    for(int j = 1; j < ndots; ++j) {
        pair tree = (i, j);
        path circ = circle(tree, 0.04);

        if(gcd(i, j) == 1) {
            draw(circ, heavyblue);
            fill(circ, heavyblue);
        } else {
            draw(circ, heavyred);
            fill(circ, heavyred);
        }

        label("$\frac{"+string(i)+"}{"+string(i+j)+"}$", tree, NE);

    }
}

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
Category:CC-BY-SA-3.0#Euclid's%20Orchard.svgCategory:Self-published work
Category:Arithmetic Category:Euclidean algorithm
Category:Arithmetic Category:CC-BY-SA-3.0 Category:Euclidean algorithm Category:Self-published work Category:Valid SVG created with Asymptote code