Prime Number problem solve |
Hello Programmers,
Today i write a article where you can find prime number in a array. This is a easy problem. We are know prime number start 2. So we need to first is input number (n>1). If n is greeter then 1. Then i check is it 2. If it is 2 then we print this is prime number. Then you check is input number divided by 3,4,5,6........
if input number divided one number then we can print this is not prime number. Otherwise we print this is prime number.
So solution is : C++ and JavaScript
//JavaScript Solution
We can solve this problem another way. Where we divided input number by 2. Because if a number divided by 2 or even number then we can print this is not prime number. So we can run a loop only odd number. This is more effective solution number 1. And this is run more first. Because we don't need check every even and odd number.
So Solution number 2 is: C++ and JavaScriipt
2 Comments
Introduction to Python Programming https://mahiuddin.me/blogs/introduction-to-python-programming/
ReplyDeletePython
ReplyDeletethank you very much