Three different ways to calculate the prime number in c++=>
In this blog, we will see how to calculate given number is prime or not in o(N) time.
here we will see three different methods to check whether the given number is prime or not.
Method 1=>
Run loop from 2 to n-1
we will run a loop from 2 to n-1 and if the number is divided by any number from 2 to n-1 we will return false that number is not a prime number otherwise we will return true.
Time complexity => O(N)
Method 2=>
Run loop from 2 to n/2
we will run a loop from 2 to n/2 and if the number is divided by any number from 2 to n/2 we will return false that number is not a prime number otherwise we will return true.
Time complexity => O(N/2) => O(N).
This program will be faster than method 1
Method 3=>
Run a loop from 2 to root √n
we will run a loop from 2 to √n and if the number is divided by any number from 2 to √n we will return false that number is not a prime number otherwise we will return true.
Time complexity => O(√n )
This program will be faster than methods 1 and 2.
The electric arc produces temperatures over 6300°F to soften metals. It is a course of suitable for high-speed welding, and it could possibly} work on both AC and DC power sources. However, care must be taken when welding thin metals because of|as a end Women’s House Shoes result of} the superior temperatures produced by this course of may injury the material. Curls help to remove sharp untreated edges from a workpiece to make it safer for handing. Curling can also result in burrs and material deformations, so care must be taken during the course of. Sawing works by progressively slicing metallic materials with a sawtooth software to make a sequence of small cuts in the metallic.
ReplyDelete