# UVa 10023

This is a stub or unfinished. Contribute by editing me. |

## Square Root[edit]

**Big Numbers**

Big numbers are to be implemented to resolve this problem. The operations of multiplication and half part are enough for this purpose.

**Big Numbers Multiplication**

Assuming it is easy to sum up big numbers and to multiply them by an number of the form , n being an integer, it becomes a trivial task to execute multiplication above these numbers.

To accomplish this task we shall consider two big numbers, a and b, which, represented as an array of integers (the least significant digit at the left) would appear as:

If both numbers are divided in half so that:

(A, B, C, D are big numbers array representations),

we would notice that:

x = digit count of a, y = digit count of b

Therefore the product sought would be so that:

Make x = y.

Then the recursive aproach shall take steps to solve the problem. The argument is based on solving the recurrence s(n) such that:

being k a constant factor.

This recurrence represents the number of time steps taken to solve the problem since two multiplications which take are held and the sum operations are of about steps.

Of course, the number n itself is of the order of , the x would be such that . Then the final time amount taken to multiply those numbers together is of .

**Square Root Algorithm**

A simple but effective square root algorithm is based on a binary search of the numbers from 1 to n.

In pseudo-code:

integer sqrt(integer n) { integer a, b, m; a:= 1; b:= n; loop { m:= (a+b)/2; if (m = a || m = b) return m; if (m*m > n) a:= m; else b:= m; } }

**Solution**

Solution to this problem is a simple combination of the two above algorithms.

--Schultz 14:35, 14 Nov 2006 (EST)