Class ModularInteger


  • class ModularInteger
    extends java.lang.Object
    Represents an integer in modular arithmetic. Its value is between 0 and m - 1 for some modulus m.

    This object is immutable; all operations create a new object.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int modulus  
      private int value  
    • Constructor Summary

      Constructors 
      Constructor Description
      ModularInteger​(int value, int modulus)
      Creates a ModularInteger.
    • Field Detail

      • value

        private final int value
      • modulus

        private final int modulus
    • Constructor Detail

      • ModularInteger

        ModularInteger​(int value,
                       int modulus)
        Creates a ModularInteger.
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • get

        public int get()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object