Square root of a number by Repeated Subtraction method | Function to return the square root of the given number ; Subtract n - th odd number ; Return the result ; Driver Code
function SquareRoot ( num ) { let count = 0 ; for ( let n = 1 ; n <= num ; n += 2 ) { num = num - n ; count += 1 ; if ( num == 0 ) break ; } return count ; } let N = 81 ; document . write ( SquareRoot ( N ) ) ;