Interface NaturalNumber

All Superinterfaces:
CardinalNumber, Comparable<RealNumber>, CountableNumber, Integer, Number, RationalNumber, RealNumber
All Known Subinterfaces:
AtLeastEight, AtLeastEighteen, AtLeastEleven, AtLeastFifteen, AtLeastFive, AtLeastFour, AtLeastFourteen, AtLeastNine, AtLeastNineteen, AtLeastOne, AtLeastSeven, AtLeastSeventeen, AtLeastSix, AtLeastSixteen, AtLeastTen, AtLeastThirteen, AtLeastThree, AtLeastTwelve, AtLeastTwenty, AtLeastTwo, AtLeastZero, FourOrEight, PositiveInteger
All Known Implementing Classes:
Eight, Eighteen, Eleven, Fifteen, Five, Four, Fourteen, Nine, Nineteen, One, Seven, Seventeen, Six, Sixteen, Ten, Thirteen, Three, Twelve, Twenty, Two, Zero

public non-sealed interface NaturalNumber extends Integer, CountableNumber
A NaturalNumber is a non-negative Integer
  • Method Details

    • plus

      default NaturalNumber plus(NaturalNumber n)
      Returns the sum of this NaturalNumber and the given NaturalNumber
      Parameters:
      n - the natural number to sum
      Returns:
      the sum of natural numbers
    • plus

      default PositiveInteger plus(PositiveInteger n)
      Returns the sum of this NaturalNumber and the given PositiveInteger
      Parameters:
      n - the positive integer to sum
      Returns:
      the sum of a natural number and positive integer
    • times

      default NaturalNumber times(NaturalNumber n)
      Returns the product of this NaturalNumber and the given NaturalNumber
      Parameters:
      n - the natural number to multiply
      Returns:
      the product of natural numbers
    • divide

      default NaturalNumber divide(NaturalNumber n)
      Returns the product of this NaturalNumber and the given NaturalNumber
      Parameters:
      n - the natural number to divide by
      Returns:
      the quotient of natural numbers
    • modulo

      default NaturalNumber modulo(NaturalNumber n)
      Returns the remainder of dividing this NaturalNumber by the given NaturalNumber
      Parameters:
      n - the natural number to modulo by
      Returns:
      the remainder of dividing natural numbers
    • count0ToN

      default Stream<NaturalNumber> count0ToN()
      Returns a Stream of all NaturalNumbers in the range from Zero to this NaturalNumber
      Returns:
      a stream of NaturalNumbers
    • count0ToNMinus1

      default Stream<NaturalNumber> count0ToNMinus1()
      Returns a Stream of all NaturalNumbers in the range from Zero to this NaturalNumber minus 1
      Returns:
      a stream of NaturalNumbers
    • countNTo0

      default Stream<NaturalNumber> countNTo0()
      Returns a Stream of all NaturalNumbers in the range from this NaturalNumber to Zero
      Returns:
      a stream of NaturalNumbers
    • countNTo1

      default Stream<NaturalNumber> countNTo1()
      Returns a Stream of all NaturalNumbers in the range from this NaturalNumber to One
      Returns:
      a stream of NaturalNumbers
    • countTo

      default Stream<NaturalNumber> countTo(NaturalNumber value)
      Returns a Stream of all NaturalNumbers in the range from this NaturalNumber to the given NaturalNumber
      Returns:
      a stream of NaturalNumbers
    • of

      static NaturalNumber of(int i)
      Returns the NaturalNumber that corresponds to the given int i
      Parameters:
      i - the int value
      Returns:
      a NaturalNumber whose value is i
      Throws:
      IllegalArgumentException - if i less than 0
    • of

      static NaturalNumber of(long l)
      Returns the NaturalNumber that corresponds to the given long l
      Parameters:
      l - the long value
      Returns:
      a NaturalNumber whose value is l
      Throws:
      IllegalArgumentException - if l less than 0
    • of

      static NaturalNumber of(BigInteger bi)
      Returns the NaturalNumber that corresponds to the given BigInteger
      Parameters:
      bi - the big integer value
      Returns:
      a NaturalNumber whose value is bi
      Throws:
      IllegalArgumentException - if bi represents an integer less than 0
    • parse

      static NaturalNumber parse(String s)
      Creates a new NaturalNumber from the given string
      Parameters:
      s - the "natural number" string
      Returns:
      the natural number represented by the string
      Throws:
      IllegalArgumentException - if the string does not represent a natural number