Skip to main content

HOW TO FIND SQUARE ROOT QUICKLY


SQUARE ROOT TIPS AND TRICKS




First we will have to remember this table 

Number
Square
Last Digit
0
0
0
1
1
1
2
4
4
3
9
9
4
16
6
5
25
5
6
36
6
7
49
9
8
64
4
9
81
1


The last digits for the squares of 1 and 9 are both 1.
The last digits for the squares of 2 and 8 are both 4.
The last digits for the squares of 3 and 7 are both 9.
The last digits for the squares of 4 and 6 are both 6.


Now suppose we want to find the square root of 3249

  Step-1 :  Ignore the last two digit i.e 49
                Consider only 32
                 Now 5^2=25 will be the number which is close to 32 because 6^2=36 is greater than 25
                Right digit of square root will be 5

Step-2 ; Now Consider last digit of given number i.e 9
              So left digit of our result will be either 3 or 7.

Step-3 : Now how to confirm whether it will be 3  or 7.
             To confirm it just add 1 to result which we got in step-1 i.e 5
             5+1=6
             Now multiply these two number i.e 5 and 6
            5*6=30 which less then left part of given number i.e 3249 
             So from 3 and 7 , we will consider the greater number i.e 7

Step- 4 : So final answer will be 57

         Note : if multiplication of result and result+1 is greater than the left part of the given number then we will have to consider the smaller one from two number as in above example we consider 7 from 3 and 7 because multiplication i.e 30 was less than left part i.e 32.



Popular posts from this blog

Bubble sort Implementation

Bubble sort  : In bubble sort ,we will select the 1st element and compare with all the remaining element, same process we will continue for all the elements as we are traveling the whole Array 2 times except the element which we have selected to compare with other elements but still it will be consider as n time.    So time complexity for bubble sort will be O(n^2).         space complexity for bubble sort will be O(1). // Bubble Sort class BubbleSort { public static void sort ( int [] array) { int n = array. length ; while ( true ) { boolean swapped = false; for ( int i = 0 ; i < n - 1 ; i++) { if (array[i + 1 ] < array[i]) { swap (array , i , i + 1 ) ; swapped = true; } } if (!swapped) break; } } private static void swap ( int [] array , int i , int j) { int temp = array[i] ;...

Object-Oriented Programming Concept in Java

OOPS( Object-Oriented Programming ) Concept in Java :   As we all know Java is Object Oriented programming language and what exactly it means in simple words to understand can be described as whatever is going to happen by Java , it will be based on some Object.  So next question can be what is Object ? , "Object is the representation or reference of Class to access its properties and use its behaviour ", now next is What is Class in java and answer to this question is "A class in java is the blueprint of Properties and Behaviours of it's own Object" as explained in my previous post  BASIC OVERVIEW OF JAVA  (SESSION 1)   Let's understand through an example : public class FirstJavaProgram { int firstNumber=10; int secondNumber=20;      public int sum(int fNum, int sNum){         return fNum+sNum;     }     public static void main(String[] args) {     //our logics ...

JAVA MEMORY LEAK, UTILISATION AND MONITORING USING JFR using Mission Control

JAVA MEMORY LEAK, UTILISATION AND MONITORING USING JFR using Mission Control Java flight recording(JFR) help us to analyse and find the root cause of any slowness in our program along with CPU usage , hot methods and garbage collection , profiling etc. To visualise we need to feed .jfr file to JDK mission control present in JDK bin folder. After successful compilation , we should run the program with below option which will generate the .jfr and feed to mission control.   command :  j ava -XX:+UnlockCommercialFeatures -XX:+FlightRecorder  -XX:StartFlightRecording=duration=200s,filename=flight.jfr -cp ./out/ path-and-class-name Below are some example to understand how this JFR can be helpful. 1. Lets consider we have created a java program in which we have used LinkList to store the elements and in same program we are using contains method inside a for loop of 1 million , in this case each time this contains method will be called then 1 million records will be sc...