Method for pefect square

70 Views Asked by At

Is there a method to verify that whether the number is a perfect square or not I know that that can be done by vedic maths by Check that the unit digit is 0 or 1 or 4 or 5 or 6 or 9 and also check that its digital root is 1 or 4 or 7 or 9 But this method fails in some cases such as the number 2284 it unit digit is 4 so it satisfies the first condition and we have 2+2+8+4=16 and 1+6=7 so it satisfies the second condition also however it is not a perfect square

1

There are 1 best solutions below

0
On BEST ANSWER

There is a $O(\ln N)$ running time algorithm to check if an integer is square number or not.

Given $N$ :

Let $x_0 = N$ and $x_{k+1} = \lfloor \frac{1}{2} \left( x_k + \lfloor \frac{N}{x_k} \rfloor \right) \rfloor$ and stop when $x_{k+1} \geq x_k$.

For $N=2284$

So $x_0 =2284$ , $x_1 = 1142$ and $x_2 = 572$ , $x_3 =287$, $x_4 = 147$ ,$x_5 = 81$, $x_6 = 54$, $x_7 =48 $ , $x_8 = 47$ , $x_9 = 47$ , stop iterations.

And because $2284-47^2 \not =0$ so $2284$ is not a square integer.