Skip to content

Update square-root description.md #2495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Nov 7, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions exercises/square-root/description.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
# Description

Given a natural radicand, return its square root.
We are launching a deep space exploration rocket and we need a way to make sure the navigation system stays on target.

Note that the term "radicand" refers to the number for which the root is to be determined.
That is, it is the number under the root symbol.
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.

Check out the Wikipedia pages on [square root][square-root] and [methods of computing square roots][computing-square-roots].
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.

Recall also that natural numbers are positive real whole numbers (i.e. 1, 2, 3 and up).
Your task is to implement a function that calculates or approximates the square root of a given number.

[square-root]: https://en.wikipedia.org/wiki/Square_root
- Try to avoid using the pre-existing math libraries of your language.
- As input you’ll be given a positive whole number, i.e. 1, 2, 3, 4…
- The function also only needs to output positive whole numbers.

Examples of some approaches you could consider are:

- Linear or binary search for a number that gives the input number when squared
- Successive approximation using Newton's or Heron's method
- Calculating one digit at a time or one bit at a time

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.

[integer-square-root]: https://en.wikipedia.org/wiki/Integer_square_root
[computing-square-roots]: https://en.wikipedia.org/wiki/Methods_of_computing_square_roots