Java Loops II

  • + 5 comments

    what is the function of math.pow

    • + 0 comments

      math.pow(2, 3) is 2^3 (3rd power of two) and will result in 8. Basic math.

    • + 0 comments

      yes

    • + 0 comments

      to the power of

    • + 0 comments

      Math.pow() is a function that is provided to us by Java. Here, it takes 2 parameters. When I pass in 2 and j, it does exponentiation (known as "power") as 2 to the j-th power. For example, Math.pow(3,5) = 3 * 3 * 3 * 3 * 3.

      Also, Math.pow() returns a double instead of an int. We "cast" it to an integer by putting

      (int)

    • + 0 comments

      exponentiation