Finding a Square Root by Enumeration

 PROBLEM: Your calculator does not include a square root function, but you need to find the square root of integer (whole) numbers. You are guaranteed that the square root is an integer. SOLUTION: We know: The calculator has a good working multiply function (and thus a means of computing the square of a number). The square root of a whole number is always less than the number. For numbers greater than 4, the square root of a number is always less than half the number. PROCEDURE: STARTing with 0 as the probable answer, Is the square of the probable answer equal to the number for which we need the square root? If so the probable answer is the actual answer. Otherwise INCREMENT the probable answer by 1, and repeat from step 2. Find Square Root of: Probable Answer Square NEXT STEP: Extend the above procedure to allow for the case when the square root is not an integer. In this case, find the pair of numbers that bracket (one smaller than, one larger than) the actual square root. Below is a demonstration of what is needed - you create the algorithm. Note: This produces, by enumeration, an approximate solution - a methodology that we will discuss later! Find Square Root of: Lower Probable Answer Upper Probable Answer Square of Upper Probable Answer

Last updated 2000/01/20