Skip to content

Commit d4f9c27

Browse files
authored
1 parent 0ec6899 commit d4f9c27

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed
Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
# Description
22

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.
44

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.
76

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.
98

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.
1110

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.
1514

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
1724
[computing-square-roots]: https://en.wikipedia.org/wiki/Methods_of_computing_square_roots

0 commit comments

Comments
 (0)