Ad
  • Default User Avatar

    Hi OlalKeith,

    So Math.sqrt(array[i]) is the square root of the array element...
    Math.sqrt(array[i]) % 1 (or square root modulo 1)is the reminder of the square root, divided by 1.
    If the result is 0, it means the square root is an integer.

    ex:
    Math.sqrt(16) = 4 --> 4 % 1 = 0 square root is an integer so the new element is the square root : 4
    Math.sqrt(17) =~ 4.123 --> 4.123 % 1 =~ 0.123 square root is not an integer so the new element is the square : 17 * 17

  • Custom User Avatar

    Hello , i am new to java.Can someone please explain to me what the if and else is actually doing in your code ?