|
1 | 1 | # Description |
2 | 2 |
|
3 | | -Given a natural radicand, return its square root. |
| 3 | +We are launching a deep space exploration rocket and we need a way to make sure the navigation system stays on target. |
4 | 4 |
|
5 | | -Note that the term "radicand" refers to the number for which the root is to be determined. |
6 | | -That is, it is the number under the root symbol. |
| 5 | +The first step in our coordinate calculation involves taking a number as input and finding another number which multiplied by itself will equal our input number, or in other words, finding the square root of our input number. |
7 | 6 |
|
8 | | -Check out the Wikipedia pages on [square root][square-root] and [methods of computing square roots][computing-square-roots]. |
| 7 | +Because the journey will be very long, we had to make our rocket’s onboard computer very power efficient so it wouldn’t drain the batteries. Unfortunately that means that we can’t rely on fancy math libraries and functions, as they would take more power. Instead we want to calculate or approximate the square root directly. |
9 | 8 |
|
10 | | -Recall also that natural numbers are positive real whole numbers (i.e. 1, 2, 3 and up). |
| 9 | +Your task is to implement a function that calculates or approximates the square root of a given number. |
11 | 10 |
|
12 | | -Avoid using built-in functions or libraries that directly compute the square root. |
13 | | -Instead, create your own approach to approximate or calculate the square root. |
14 | | -It is possible to calculate the square root of any natural number using only natural numbers in the calculation. |
| 11 | +* Try to avoid using the pre-existing math libraries of your language. |
| 12 | +* As input you’ll be given a positive whole number, i.e. 1, 2, 3, 4… |
| 13 | +* The function also only needs to output positive whole numbers. |
15 | 14 |
|
16 | | -[square-root]: https://en.wikipedia.org/wiki/Square_root |
| 15 | +Examples of some approaches you could consider are: |
| 16 | + |
| 17 | +* Linear or binary search for a number that gives the input number when squared |
| 18 | +* Successive approximation using Newton's or Heron's method |
| 19 | +* Calculating one digit at a time or one bit at a time |
| 20 | + |
| 21 | +You can check out the Wikipedia pages on [integer square root][integer-square-root] and [methods of computing square roots][computing-square-roots] to help with choosing a method of calculation. |
| 22 | + |
| 23 | +[integer-square-root]: https://en.wikipedia.org/wiki/Integer_square_root |
17 | 24 | [computing-square-roots]: https://en.wikipedia.org/wiki/Methods_of_computing_square_roots |
0 commit comments