You might like to read our Introduction to Squares and Square Roots first.

An online square root calculator helps you to find the square & nth root of any positive as well as negative numbers. Also, this sqrt calculator shows you whether the given number is a perfect square root or not. For example; \(4\), \(9\) & \(16\) are the perfect squares of \(2\), \(3\) & \(4\) respectively.

This context is packed with lots of helpful information including the square root formula, how to find it sqrt step-by-step & much more. Read on!

You can check an online factor calculator if you need to determine the factors and the pairs of factors of positive or negative integers.

Given an integer **X**, find its square root. If **X** is not a perfect square, then return **floor(√x)**.

Input:x = 4Output:2Explanation:The square root of 4 is 2.

Input:x = 11Output:3Explanation:The square root of 11 lies in between 3 and 4 so floor of the square root is 3.

**Naive Approach:** To find the floor of the square root, try with all-natural numbers starting from 1. Continue incrementing the number until the square of that number is greater than the given number.

- Create a variable (counter)
and take care of some base cases, (i.e when the given number is 0 or 1).**i** - Run a loop until
, where n is the given number. Increment i by 1.**i*i <= n** - The floor of the square root of the number is
*i – 1*

Below is the implementation of the above approach:

When we talk about numbers, a root of a number is another number that produces a whole number when it is raised to a certain power (also called an exponent).

Using the number 64 as an example we can see that the 3rd root of the number is 4:

4^{3} = 4 × 4 × 4 = 64

The third root is also commonly known as the cube root and it is very commonly used for solving cubic equations — in particular, to solve the dimensions of a three dimensional object with a certain volume.

This article is about the more popular and commonly used **square root**, however.

The square root of a number is the second root. So while 4 is the cube root of 64, it is the 2nd, or square root, of 16:

4^{2} = 4 × 4 = 16

It’s likely that you have seen or heard of the square root of a number before and the symbol that accompanies it, which is called the radical symbol: √. Any number that is shown alongside this symbol are called radical terms, or radicals for short.

Enter your number in box A below and click «Calculate» to work out the square root of the given number.

- Perfect Square Numbers
- Rational and Irrational Numbers
- Practice Square Roots Using Examples
- What are square roots and why do we care?
- How do we write out square roots?
- What do we use square roots for?
- List of Perfect Squares
- How to Square A Number
- Example: What is 3 squared?
- Squares From to
- Negative Numbers
- Square Roots
- Decimal Numbers
- Negatives
- Example: (−3) squared
- Example: What are the square roots of 25?
- The Square Root Symbol
- Example: What is 25?
- Example: What is √36 ?
- Perfect Squares
- Calculating Square Roots
- Example: what is √10?
- The Easiest Way to Calculate a Square Root
- A Fun Way to Calculate a Square Root
- How to Guess
- Square Root Day
- Square root
- Square roots without a calculator
- Sample Problems
- An Exponent of a Half
- Java
- Two Square Roots
- Example: Solve w2 = a
- How to Find Square Root (Step-by-Step)
- Square Root of xy
- Example: What is √(100×4) ?
- Example: What is √8√2 ?
- Example: What is √(−8 × −2) ?
- Why does √ = √√ ?
- Python3
- The Square Root Symbol
- Example: What is √36 ?
- Java
- Python3
- Square Root of Fractions
- Frequently Ask Questions (FAQ’s)
- Can a number have more than one square root?
- Is the √2 is a rational number?
- Are square roots rational?
- How to find the square root without a calculator?
- How to get rid of a square root in an equation?
- Why Is This Important?
- Example: Solve x2 − 9 = 0
- Example: Solve for x in (x − 3)2 = 16
- C++
- Square root an integer using Binary search
- PHP
- Python3
- Javascript
- In a Nutshell
- C++
- What is Square Root?
- Javascript
- How to Use the Square root Calculator
- Principal Square Root
- Example:
- Squares
- Example: What is 3 squared?
- Javascript
- PHP
- Python3
- Java
- C++
- Javascript
- Square Root of Negative Number
- Square root an integer using built-in functions
- Square Root
- Negative Numbers
- Example: What is minus 5 squared?
- C++
- Java
- References
- End-Note
- Definition

## Perfect Square Numbers

When the square root of a given number is a whole number, this is called a perfect square. Perfect squares are important for many mathematical functions and are used in everything from carpentry through to more advanced topics like physics and astronomy.

If we look at the number 16, we know that the square root is 4, and since this is a whole number, we can say that 16 is a perfect square:

√16 = 4

## Rational and Irrational Numbers

Another common question you might find when working with the roots of a number is whether the given number is rational or irrational. Rational numbers can be written as a fraction and irrational numbers can’t.

The quickest way to check if a number is rational or irrational is to determine if it is a perfect square. If it is, then it’s a rational number, but if it is not a perfect square then it is an irrational number.

We already know that 16 is a rational number then, because we know it is a perfect square. The number 24, however, is an irrational number because it is not a perfect square:

√24 = 4.899

## Practice Square Roots Using Examples

If you want to continue learning about square roots, take a look at the random calculations in the sidebar to the right of this blog post.

## What are square roots and why do we care?

The square root of a number is a number that, when multiplied by itself, equals the desired value. So, for example, the square root of 49 is 7 (7×7=49). The process of multiplying a number times itself is called **squaring**.

Numbers whose square roots are whole numbers, (or more accurately positive integers) are called perfect square numbers. Numbers with decimals aren’t perfect square roots.

All positive numbers will have a positive number as their square root, called the principal, and a negative number. These numbers are all known as real numbers.

All negative numbers will have a complex number as their square root. A complex number is a number multiplied by *i. i *is the «imaginary» square root of -1. It’s called imaginary, but it does exist to mathematicians.

### How do we write out square roots?

A square root equation is written out using a radical sign or radical symbol (). The number that we want to get the root of comes after or under the tail of the radical (for example 3 if we wanted to find the square root of 3). The number after the radical is called the radicand. On a calculator, instead of the radical, you might see «sqrt».

### What do we use square roots for?

It may be a bit hard to picture it, but square roots are some of the most useful numbers around. Square root functions are super important for physics equations of all kinds. They’re also valuable for statistics; statisticians use square roots all the time in analyzing the correlation between different points of data.

### List of Perfect Squares

Use this table to find the squares and square roots of numbers from **1** to **100**.

You can also use this table to estimate the square roots of larger numbers.

- For instance, if you want to find the square root of
**2000**, look in the**middle**column until you find the number that is closest to 2000. The number in the middle column that is closest to 2000 is**2,025**. - Now look in at the number to the
**left of 2,025**to find its square root. The square root of 2,025 is**45.** **Therefore,****the approximate square root of 2,000 is 45**.

**To get a more exact number, you will have to use a calculator (44.721 is the more exact square root of 2,000).**

**Tucking in for lengthy study session? You might be interested in our list of the best desk chairs of 2020.**

**NOTE: Square roots in this table are rounded to the nearest thousandth.**

** Mean and Median**

** Numbers and Formulas**

** Finding Square Roots**

** **

** **

First learn about Squares, then Square Roots are easy.

## How to Square A Number

To square a number: **multiply it by itself**.

### Example: What is 3 squared?

«Squared» is often written as a little 2 like this:

This says **«4 Squared equals 16»**

(the little 2 says

the number appears twice in multiplying)

## Squares From to

## Negative Numbers

We can also square **negative numbers**.

That was interesting!

When we square a **negative** number we get a **positive** result.

Just the same as squaring a positive number:

## Square Roots

A **square root** goes the other way:

3 squared is 9, so a **square root of 9 is 3**

It is like asking:

What can we multiply by itself to get this?

Here are some more squares and square roots:

## Decimal Numbers

It also works for decimal numbers.

Using the sliders:

- What is the square root of
**8**? - What is the square root of
**9**? - What is the square root of
**10**? - What is
**1**squared? - What is
**1.1**squared? - What is
**2.6**squared?

## Negatives

We discovered earlier that we can square negative numbers:

### Example: (−3) squared

(−3) × (−3) = **9**

And of course 3 × 3 = **9** also.

So the square root of 9 could be **−3** or **+3**

### Example: What are the square roots of 25?

(−5) × (−5) = 25

5 × 5 = 25

So the square roots of 25 are **−5** and **+5**

## The Square Root Symbol

We use it like this:

and we say **«square root of 9 equals 3»**

### Example: What is 25?

25 = 5 × 5, in other words when we multiply

5 by itself (5 × 5) we get 25

**So the answer is:**

√25 = 5

But wait a minute! Can’t the square root **also be −5**? Because (−5) × (−5) = **25** too.

- Well the
**square root of 25**could be −5 or +5. - But when we use the
**radical symbol**we only give the**positive (or zero) result**.

### Example: What is √36 ?

Answer: 6 × 6 = 36, so **√36 = 6**

## Perfect Squares

The Perfect Squares (also called «Square Numbers») are the squares of the integers:

Try to remember them up to 12.

## Calculating Square Roots

It is easy to work out the square root of a perfect square, but it

is **really hard** to work out other square roots.

### Example: what is √10?

Well, 3 × 3 = 9 and 4 × 4 = 16, so we can guess the answer is between 3 and 4.

- Let’s try 3.5:
*3.5 × 3.5 = 12.25* - Let’s try 3.2:
*3.2 × 3.2 = 10.24* - Let’s try 3.1:
*3.1 × 3.1 = 9.61* - …

Getting closer to 10, but it will take a long time to get a good answer!

At this point, I get out my calculator and it says:

But the digits just go on and on, without any pattern.

So even

the calculator’s answer is **only an approximation !**

*Note: numbers like that are called Irrational Numbers, if you want to know more.*

## The Easiest Way to Calculate a Square Root

And also use your common sense to make sure you have the right answer.

## A Fun Way to Calculate a Square Root

There is a fun method for calculating a square root that gets more and more accurate each time around:

- Our first attempt got us from 4 to
**3.25** - Going again (
*b to e*) gets us:**3.163** - Going again (
*b to e*) gets us:**3.1623**

And so, after 3 times around the answer is 3.1623, which is pretty good, because:

** 3.1623 x 3.1623 = 10.00014**

### How to Guess

In that case we could think «82,163» has 5 digits, so the square root might have 3 digits (100×100=10,000), and the square root of 8 (the first digit) is about 3 (3×3=9), so 300 is a good start.

### Square Root Day

The 4th of April 2016 is a Square Root Day, because the date looks like **4/4/16**

The next after that is the 5th of May 2025 (5/5/25)

309,310,315, 1082, 1083, 2040, 3156, 2041, 2042, 3154

The number system is the system defined for the different numbers and the way they could be arranged. There are many types of number systems but mostly 4 types are well known. They are Binary number systems, Decimal number systems, Octal number systems, and Hexadecimal number systems. The decimal number system is mostly used in mathematics, it involves numbers from 0-9. There are multiple operations done on the numbers, for example, finding squares and square roots of numbers, lets learn in detail about the square roots of the numbers,

### Square root

The square root of a number is a value which when multiplied with itself gives the original number. For example, the square root of 9 is 3, when 3 is multiplied by itself, the original number obtained is 9. The symbol that denotes square root in mathematics is **√.**

This symbol (√) is called radical and the number inside the radical symbol is known as radicand. The number or the value present inside the root symbol might be a perfect square or an imperfect square. For example- 4 is a perfect square whereas 3 is an imperfect square. So, based on the nature of value inside the root, the final answer or the square root may be a natural number of a decimal number.

Now let’s find out how to calculate the square root of different numbers.

### Square roots without a calculator

As above defined, the square root of a number is the value which when multiplied with itself will provide the original number only. There are three ways to find square root without a calculator

This is a long but simple method to find the square root of any number. Prime factorization involves finding factors of that number and then pairing the common numbers in a pair of two. finally, taking the square roots of the prime factors. Let’s see an example of this,

**Question: find the square root of 484**

484=2 × 2 × 11 × 11

So, √484= √(2 × 2 × 11 × 11) = 2 × 11 =22

**Guess & Check method**

This method is used to give the approximate value of any number. The guess method saves time as it gives an approximate range of values between which the root exists. it is more efficient when the number inside the root is an imperfect number. Let’s see an example of this,

**Question: find the square root of 20.**

Start guess and check method by noting that since √16 = 4 and √25 = 5, then √20 must be between 4 and 5. As second step, in order to reach nearer to the actual answer, lets take a number between 4 and 5. lets assume it to be 4.5. Lets do square of 4.5 which comes out to be 20.25, which is greater than 20, therefore the root must be smaller than 4.5, lets choose 4.4, square of 4.4 is 19.36. thus,

the most approx and accurate root of 20 is 4.4

**Long division method**

It is a very easy way to get the square root of imperfect squares. The long division method is mostly preferred over the other methods since it provides an accurate answer. Let’s understand this algorithm using an example,

**Question: find the square root of 627**

Step 1Group the numbers in pairs from right to left ,leaving one or two digit in left (here its 6).

Step 2Think of a number whose square is less than the first number (6), its 2, So,write it like this –

Step 3Is to square the number 2 and write the result beneath 6 and then subtract as shown below,

Step 4Multiply the quotient by 3 and and write it down in parenthesis with an empty line next to it as shown below,

Step 5Now find out the number which when multiplied by forty something would be lesser than 225. Lets guess 5. then 45×5=225, which is less than 227, So write it as shown below-

Step 6Then repeating step 4, multiply the quotient with 2 write it down in parenthesis with an empty line next to it as shown below,

Step 7Repeating step 5, find out the number which when multiplied by five hundred something would be lesser than 2000. Lets guess 5, then 505×5=2525, which is bigger than 2000, lets guess 4, then 504×3=1512. So write it as shown below,

The square root of 627 with two decimal place is 25.03, which is accurate.

### Sample Problems

**Question 1: Find the square root of 144**

144=2 × 2 × 2 × 2 × 3 × 3

So √144= √(2 × 2 × 2 × 2 × 3 × 3) = 2 × 2 × 3 =12

**Question 2:** **Find the square root of 169**

169=13 × 13

So √144= √(13 × 13) = 13

**Question 3: Find the square root of 6 by the Guess and check method.**

Start guess and check the method by noting that since √9 =3 and √4 = 2, then √6 must be between 2 and 3. As the second step, in order to reach nearer to the actual answer, let’s take a number between 2 and 3. Let’s assume it to be 2.5. Let’s do a square of 2.5 which comes out to be 6.25, which is greater than 6. therefore the root must be smaller than 2.5. Let’s choose 2.4, square of 2.4 is 15.76. Thus, the most approx and accurate root of 6 is 2.4

## An Exponent of a Half

A square root can also be written as a fractional exponent of one-half:

but only for **x** greater than or equal to 0

## Java

` `

`public`

`static`

`int`

`findSquareRoot(`

`int`

`x)`

` `

`double`

`result = Math.exp(Math.log(x) / `

`2`

`);`

` `

`int`

`floorResult = (`

`int`

`)Math.floor(result);`

` `

`int`

`x = `

`11`

`;`

` `

`int`

`squareRoot = findSquareRoot(`

## Two Square Roots

There can be a **positive** and **negative** square root!

This is important to remember.

### Example: Solve w^{2} = a

**w = √a** and **w = −√a**

## How to Find Square Root (Step-by-Step)

To prepare for the calculation of square root, then you should remember the basic perfect square root. As the sqrt of \(1, 4, 9, 16, 25, 100\) is \(1, 2, 3, 4, 5,\) and \(10\).

These are the simplest square roots because they give every time an integer, but what when a number has not a perfect square root? For example, you have to estimate the sqrt of 54?

- As you know \(sqrt {49} = 7\) & \(\sqrt {64} = 8\). So, the \(\sqrt {54}\) is between the \(8\) and \(7\).
- The number \(54\) is closer to \(49\) than \(64\). So, you can try guessing \(\sqrt {54} = 7.45\)
- Then, by squaring \(7.45\), \((7.45)^2 = 55.5\) which is greater than \(54\). So you should try the smaller number. Let’s take \(7.3\)
- By taking the square of \(7.3\), it gives \(53.29\) which is close to \(54\).
- It means the square root of \(54\) is between \(7.3\) & \(7.4\).

Let’s take another example:

What is a square root of \(27\)?

As the \(27\) is not the perfect square of any number. So, we have to simplify it as:

Our square root calculator considers these formulas & simplification techniques to solve the sqrt of any number or any fraction.

` `

`static`

`int`

`floorSqrt(`

`int`

`x)`

` `

`int`

`i = 1, result = 1;`

` `

`result = i * i;`

` `

`return`

`i - 1;`

` `

`static`

`public`

`void`

`Main()`

` `

`int`

`x = 11;`

## Square Root of xy

When two numbers are multiplied **within** a square root, we can split it into a multiplication of two square roots like this:

√ = √√

but only when **x** and **y** are **both greater than or equal to 0**

### Example: What is **√(100×4)** ?

= √(100) × √(4)

= 10 × 2

And **√√ = √** :

### Example: What is **√8√2** ?

### Example: What is **√(−8 × −2)** ?

√(−8 × −2) = √(−8) × √(−2)

We seem to have fallen into some trap here!

We can use Imaginary Numbers,

but that leads to a **wrong** answer of **−4**

The rule only works when **x** and **y** are both greater than or equal to 0

So we can’t use that rule here.

Instead just do it this way:

√(−8 × −2) = √16 = +4

### Why does √ = √√ ?

We can use the fact that squaring a square root gives us the original value back again:

(√)^{2} = a

Assuming **a** is not negative!

We can do that for xy:(√)^{2} = xy

And also to x, and y, separately:(√)^{2} = (√)^{2}(√)^{2}

Use a^{2}b^{2} = (ab)^{2}:(√)^{2} = (√√)^{2}

Remove square from both sides^{}:√ = √√

## Python3

` `

`if`

`(x `

`=`

`=`

`0`

`or`

`x `

`=`

`=`

`1`

`):`

` `

`result `

`=`

`1`

` `

`while`

`(result <`

`=`

`x):`

` `

`i `

`+`

`=`

`1`

` `

`result `

`=`

`i `

`*`

`i`

` `

`return`

`i `

`-`

`1`

`x `

`=`

`11`

## The Square Root Symbol

We can use it like this:

we say «square root of 9 equals 3»

### Example: What is √36 ?

Answer: 6 × 6 = 36, so **√36 = 6**

## Java

` `

`static`

`int`

`floorSqrt(`

`int`

`x)`

` `

`int`

`i = `

`1`

`, result = `

`1`

`;`

` `

`result = i * i;`

` `

`return`

`i - `

`1`

`;`

` `

`int`

`x = `

`11`

`;`

`int`

`floorSqrt(`

`int`

`x)`

` `

`long`

`start = 1, end = x / 2, ans = 0;`

` `

`int`

`mid = (start + end) / 2;`

` `

`if`

`(mid * mid == x)`

` `

`start = mid + 1;`

` `

`ans = mid;`

` `

`end = mid - 1;`

` `

`int`

`x = 11;`

## Python3

` `

`result `

`=`

`math.exp(math.log(x) `

`/`

`2`

`)`

` `

`floorResult `

`=`

`math.floor(result)`

` `

`if`

`floorResult `

`*`

`floorResult `

`=`

`=`

`x:`

`x `

`=`

`11`

`squareRoot `

`=`

`findSquareRoot(x)`

## Square Root of Fractions

√9 / √25 = 3 / 5 = 0.6

## Frequently Ask Questions (FAQ’s)

**Can a number have more than one square root?**

Yes, the positive numbers have more than one sqrt, one is positive & the other is negative.

**Is the √2 is a rational number?**

No, it is an irrational number.

The square root of 2 cannot be expressed as the quotient of two numbers.

**Are square roots rational?**

Some roots are rational while others are irrational.

**How to find the square root without a calculator?**

**Step 1:**Estimate: first of all, estimate the square root. You need to get as close as you can by simply determining two perfect square roots the given number is between**Step 2:**Divide: now, you need to divide the given number by one of those square roots**Step 3:**Average: you need to take the average of the result of step 2 as well as the root**Step 4:**Now, you have to use the result of step 3 to repeat steps 2 & 3 until you get a number, which is accurate enough for the solution.

**How to get rid of a square root in an equation?**

To solve an equation that has a square root in it:

- First, you need to isolate the square root on one side of the given equation
- Then, simply square both sides of the equation and keep solving for the variable
- Finally, verify your work, all you need to substitute the obtained value of variable into the original equation

## Why Is This Important?

Why is this «plus or minus» important? Because we don’t want to miss a solution!

### Example: Solve x^{2} − 9 = 0

x^{2} − 9 = 0

Move 9 to right:x^{2} = 9

x = ±√9

x = ±3

The «» tells us to include the «−3» answer also.

### Example: Solve for x in (x − 3)^{2} = 16

(x − 3)^{2} = 16

x − 3 = ±√16

x − 3 =

Add 3 to both sides:x = 3 ± 4

x = 7 or −1

Check: (7−3)^{2} = 4^{2} = 16

Check: (−1−3)^{2} = (−4)^{2} = 16

## C++

`using`

`namespace`

`std;`

`int`

`floorSqrt(`

`int`

`x)`

` `

`int`

`start = 1, end = x / 2, ans;`

` `

`int`

`mid = (start + end) / 2;`

` `

`int`

`sqr = mid * mid;`

` `

`if`

`(sqr == x)`

` `

`start = mid + 1;`

` `

`ans = mid;`

` `

`end = mid - 1;`

` `

`int`

`x = 11;`

` `

`cout << floorSqrt(x) << endl;`

## Square root an integer using Binary search

The idea is to find the largest integer

whose square is less than or equal to the given number. The values ofii * iis monotonically increasing, so the problem can be solved using binary search.

**Below is the implementation of the above idea:**

- Base cases for the given problem are when the given number is
**0**or**1**, then return**X**; - Create some variables, for storing the lower bound say
**l = 0,**and for upper bound**r = X / 2**(i.e, The floor of the square root of x cannot be more than x/2 when x > 1). - Run a loop until
, the search space vanishes**l <= r** - Check if the square of mid
**(****mid = (l + r)/2****)**is less than or equal to**X**, If yes then search for a larger value in the second half of the search space, i.e**l = mid + 1**, update**ans = mid** - Else if the square of mid is more than
**X**then search for a smaller value in the first half of the search space, i.e**r = mid – 1** - Finally, Return the
**ans**

Below is the implementation of the above approach:

## PHP

` `

`$i`

`= 1;`

` `

`$result`

`= 1;`

` `

`while`

`(`

`$result`

`<= `

`$x`

`)`

` `

`$result`

`= `

`$i`

`* `

`$i`

`;`

` `

`return`

`$i`

`- 1;`

`$x`

`= 11;`

` `

`public`

`static`

`int`

`floorSqrt(`

`int`

`x)`

` `

`int`

`start = 1, end = x / 2, ans = 0;`

` `

`int`

`mid = (start + end) / 2;`

` `

`if`

`(mid * mid == x)`

` `

`start = mid + 1;`

` `

`ans = mid;`

` `

`end = mid - 1;`

` `

`static`

`public`

`void`

`Main()`

` `

`int`

`x = 11;`

`public`

`class`

`Program`

` `

`public`

`static`

`int`

`FindSquareRoot(`

`int`

`x)`

` `

`double`

`result = Math.Exp(Math.Log(x) / 2);`

` `

`int`

`floorResult = (`

`int`

`)Math.Floor(result);`

` `

`if`

`(floorResult * floorResult == x)`

` `

`public`

`static`

`void`

`Main()`

` `

`int`

`x = 11;`

` `

`int`

`squareRoot = FindSquareRoot(x); `

## Python3

` `

`if`

`(x `

`=`

`=`

`0`

`or`

`x `

`=`

`=`

`1`

`):`

` `

`start `

`=`

`1`

` `

`end `

`=`

`x`

`/`

`/`

`2`

` `

`while`

`(start <`

`=`

`end):`

` `

`mid `

`=`

`(start `

`+`

`end) `

`/`

`/`

`2`

` `

`if`

`(mid`

`*`

`mid `

`=`

`=`

`x):`

` `

`if`

`(mid `

`*`

`mid < x):`

` `

`start `

`=`

`mid `

`+`

`1`

` `

`ans `

`=`

`mid`

` `

`end `

`=`

`mid`

`-`

`1`

`x `

`=`

`11`

## Javascript

` `

`let i = 1;`

` `

`let result = 1;`

` `

`while`

`(result <= x)`

` `

`result = i * i;`

` `

`return`

`i - 1;`

`let x = 11;`

**Time Complexity:**O(√X). Only one traversal of the solution is needed, so the time complexity is O(√X).**Auxiliary Space:**O(1).

*Thanks, Fattepur Mahesh for suggesting this solution.*

## In a Nutshell

When we have:r^{2} = x

r = ±√x

## C++

`using`

`namespace`

`std;`

`int`

`countSquares(`

`int`

`x)`

` `

`int`

`sqr = `

`sqrt`

`(x);`

` `

`int`

`result = (`

`int`

`)(sqr);`

` `

`int`

`x = 9;`

` `

`cout << (countSquares(x));`

## What is Square Root?

For example, \(3\) and \(-3\) are said to be as the square roots of 9, since \(3^2 = (-3) ^2 = 9\). You can try the square root calculator to simplify the principal square root for the given input.

The given formula is considered to represent the square root:

Also, you can try our online exponent calculator that helps you to calculate the value of any number raised to any power.

## Javascript

` `

`let start = 1;`

` `

`let end = x/2;`

` `

`while`

`(start <= end)`

` `

`let mid = (start + end) / 2;`

` `

`if`

`(mid * mid == x)`

` `

`if`

`(mid * mid < x)`

` `

`start = mid + 1;`

` `

`ans = mid;`

` `

`end = mid-1; `

`let x = 11;`

`document.write(floorSqrt(x) + `

`"<br>"`

`);`

**Time Complexity:**O(log(X)).**Auxiliary Space:**O(1).

Thanks to Gaurav Ahirwar for suggesting the above method.

`int`

`floorSqrt(`

`int`

`x)`

` `

`int`

`i = 1, result = 1;`

` `

`result = i * i;`

` `

`return`

`i - 1;`

` `

`int`

`x = 11;`

## How to Use the Square root Calculator

There’s no doubt, finding square root manually quite complex, but becomes easy with this roots calculator. Hold the given steps and get the exact sqrt calculations:

- First of all, hit the tab to choose the square root or nth root for any number.
- Very next, enter the number for which you want to do the calculation according to the selected option.
- Lastly, click on calculate button.

Once done, the calculator shows:

- Square root of the number.
- The nth root of the number.
- Step-by-Step calculation
- Tells either the number has a perfect square root or not

It doesn’t matter at all what values you entered, this online square roots calculator simplifying the given number accurately by using the sqrt maths formula.

## Principal Square Root

So if there are really two square roots, why do people say √ =

There **are** two square roots, but **the symbol ** means **just the principal square root**.

### Example:

The square roots of 36 are 6 **and** −6

But √ = (not −6)

The Principal Square Root is sometimes called the Positive Square Root (but it can be zero).

## Squares

### Example: What is 3 squared?

«Squared» is often written as a little 2 like this:

This says **«4 Squared equals 16»**

(the little 2 means

the number appears twice in multiplying, so **4×4**=16)

## Javascript

` `

`let result = Math.exp(Math.log(x) / 2);`

` `

`let floorResult = Math.floor(result);`

`let x = 11;`

`let squareRoot = findSquareRoot(x);`

**Time Complexity:** O(1), The time complexity of the given approach is O(1) since it uses only one mathematical formula exp(log(x) / 2) which is constant time, and a few arithmetic operations, comparisons, and function calls that take constant time as well. Therefore, the time complexity of this algorithm is constant or O(1).**Auxiliary Space:** O(1), The space complexity of the given approach is O(1) as it only uses a constant amount of extra space. It declares two integer variables, result and floorResult, which each take constant space, and there is no dynamic memory allocation or recursive calls. Therefore, the space complexity of this algorithm is constant or O(1).

`static`

`int`

`countSquares(`

`int`

`x)`

` `

`int`

`sqr = (`

`int`

`)`

`sqrt`

`(x);`

` `

`int`

`result = (`

`int`

`)(sqr);`

` `

`int`

`x = 9;`

## PHP

` `

`$start`

`= 1; `

`$end`

`= `

`$x`

`/2; `

`$ans`

`;`

` `

`while`

`(`

`$start`

`<= `

`$end`

`)`

` `

`$mid`

`= (`

`$start`

`+ `

`$end`

`) / 2;`

` `

`if`

`(`

`$mid`

`* `

`$mid`

`== `

`$x`

`)`

` `

`if`

`(`

`$mid`

`* `

`$mid`

`< `

`$x`

`)`

` `

`$start`

`= `

`$mid`

`+ 1;`

` `

`$ans`

`= `

`$mid`

`;`

` `

`$end`

`= `

`$mid`

`-1; `

`$x`

`= 11;`

## Python3

` `

`sqrt `

`=`

`x`

`*`

`*`

`0.5`

` `

`result `

`=`

`int`

`(sqrt)`

## Java

` `

`static`

`int`

`countSquares(`

`int`

`x)`

` `

`int`

`sqr = (`

`int`

`)Math.sqrt(x);`

` `

`int`

`result = (`

`int`

`)(sqr);`

` `

`int`

`x = `

`9`

`;`

## C++

`using`

`namespace`

`std;`

`int`

`floorSqrt(`

`int`

`x)`

` `

`int`

`i = 1, result = 1;`

` `

`result = i * i;`

` `

`return`

`i - 1;`

` `

`int`

`x = 11;`

` `

`cout << floorSqrt(x) << endl;`

` `

`static`

`int`

`countSquares(`

`int`

`x)`

` `

`int`

`sqr = (`

`int`

`)Math.Sqrt(x);`

` `

`int`

`result = (`

`int`

`)(sqr);`

` `

`int`

`x = 9;`

## Javascript

` `

`var`

`sqr = parseInt( Math.sqrt(x));`

` `

`var`

`result = parseInt(sqr);`

` `

`var`

`x = 9;`

**Time Complexity:** O(log(X))**Auxiliary Space:** O(1)

There can be many ways to solve this problem. For example, the Babylonian Method is one way.

**Another Approach to Solve This Problem Using Exponential Function:**

The basic idea behind the method is to calculate the exponential of the logarithm of the integer divided by two.

**Below are steps to implement the above approach:**

- Take the integer value as input and save it in a variable.
- Use the exponential function exp() and the logarithmic function log() from the <cmath> library to calculate the square root of the integer. exp(log(x) / 2) will give the square root of x.
- Use the floor() function to get the integer part of the result.
- Check whether the square of the floor result is equal to the input x.
- If the square of the floor result is equal to the input x, then return the floor result as it is the square root of x.
- If the square of the floor result is not equal to the input x, then return the floor result as the floor of the square root

**Below is the implementation of the above approach:**

## Square Root of Negative Number

At school level, we have been taught that the square root of negative numbers cannot exist. But, the mathematicians introduce the general set of numbers (Complex numbers). As:

$$ x = a + bi $$

Where, a is real number & b is an imaginary part. The iota \((i)\) is a complex number with a value:

What is the square root of -17 = √-17 = √-1 * 17 = √ (-1) √17 = 17i

## Square root an integer using built-in functions

Below is the implementation for finding the square root using the built-in function.

## Square Root

A **square root** goes the other direction:

3 squared is 9, so a **square root of 9 is 3**

It is like asking:

What can I multiply by itself to get this?

## Negative Numbers

We can also square negative numbers.

### Example: What is **minus 5 squared**?

- square the 5, then do the minus?
- or square (−5)?

It isn’t clear! And we get different answers:

- square the 5, then do the minus: −(5×5) =
- square (−5): (−5)×(−5) =

So let’s make it clear by using «( )».

That was interesting!

When we square a **negative** number we get a **positive** result.

Just the same as when we square a positive number:

Now remember our definition of a square root?

A square root of x is **a number r** whose square is x:

r^{2} = x

r is a square root of x

And we just found that:

(+5)^{2} = 25

(−5)^{2} = 25

So **both +5 and −5** are square roots of 25

## C++

`using`

`namespace`

`std;`

`int`

`findSquareRoot(`

`int`

`x)`

` `

`double`

`result = `

`exp`

`(`

`log`

`(x) / 2);`

` `

`int`

`floorResult = `

`floor`

`(result);`

` `

`int`

`x = 11;`

` `

`int`

`squareRoot = findSquareRoot(`

` `

`cout << squareRoot << endl; `

## Java

` `

`public`

`static`

`int`

`floorSqrt(`

`int`

`x)`

` `

`long`

`start = `

`1`

`, end = x / `

`2`

`, ans = `

`0`

`;`

` `

`long`

`mid = (start + end) / `

`2`

`;`

` `

`if`

`(mid * mid == x)`

` `

`start = mid + `

`1`

`;`

` `

`ans = mid;`

` `

`end = mid - `

`1`

`;`

` `

`int`

`x = `

`11`

`;`

## References

From the source of Wikipedia : Definition, uses & properties

From the site of virtualnerd : Square root of fractions

From the source of khanacademy : Square root of negative numbers

Other languages: Karekök Hesaplama, Kalkulator Akar Kuadrat, Kalkulator Pierwiastków, Wurzel Ziehen Rechner, 平方根 計算, 제곱근 계산, Kalkulačka Odmocniny, Calculadora De Raiz Quadrada, Calculatrice Racine Carré, Calculadora Raiz Cuadrada, Calcolo Radice Quadrata, Калькулятор Корней, حاسبة الجذر التربيعي, Neliöjuuri Laskin, Kvadratrot Kalkulator, Kvadratni Koren Kalkulator.

## End-Note

Square roots are frequently appearing in mathematical formulas including quadratic formulas, discriminant as well as in many physics laws. Further, it is used in many places in daily life, used by engineers, carpenters construction managers, medical assistants, and many others. When it comes to calculations for a large number, it is very tricky & complex. Simply, try the online square root calculator that helps you to determine the square root according to your need.

## Definition

Here is the definition:

A square root of x is **a number r** whose square is x:

r^{2} = x

r is a square root of x