Source code for FiniteCyclicGroupDemo.java

What follows is the highlighted source code with comments. You can also download this file directly: FiniteCyclicGroupDemo.java.

/*
 * This work by W. Patrick Hooper is free of known copyright restrictions.
 * The work is in the public domain.
 * 
 * Author's website: <a href="http://wphooper.com">http://wphooper.com</a>. 
 */
package finitecyclicgroup;

/**
 *  This program demonstrates the use of the FiniteCyclicGroup and FiniteCyclicGroupElement classes.
 * 
 * @author W. Patrick Hooper <wphooper@gmail.com>
 * @version 1
 */
public class FiniteCyclicGroupDemo {

    public static void main(String[] args) {
        // Construct the group Z / 5Z.
        FiniteCyclicGroup g = new FiniteCyclicGroup(5);

        FiniteCyclicGroupElement a = g.convert(8);
        System.out.println("a=" + a);
        FiniteCyclicGroupElement b = g.convert(19);
        System.out.println("b=" + b);
        FiniteCyclicGroupElement c = g.subtract(a, b);
        System.out.println("a-b=" + c); 
        System.out.println("-a=" + g.negate(a));         
    }
}
HOOPER >>>>> JAVA TUTORIAL
Last modified on August 17, 2018.
[check html] [check css]