In this Post we are going to learn how to write a program to check whether a given integer number by user is a prime number or not in Python programming language.
If given number is prime then our logic will assign value 0 to a temp variable and will print “number is prime” and if the number is not prime then our logic will assign value 1 to a temp variable program will print “number is not prime”.
Before directly moving on the writing prime number program in Python, first you should know
What is prime number?
In Mathematical term, A prime number is a number which can be divided by only 1 and number itself.
For example : 2, 3, 5, 7, 13,…
Here 2, 3 or any of the above number can only be divided by 1 or number itself.
How our program will behave?
Suppose if someone gives an input 2 then our program should give output “given number is a prime number”.
And if someone gives 4 as an input then our program should give output “given number is not a prime number”.
Python program to check given number is prime or not
def isPrimeOrNot(n):
if n==1:
return "not a Prime"
for i in range(2,n):
if n%i==0:
return "given number is not a prime number."
break
else:
return "given number is a prime number."
print(isPrimeOrNot(11))
Same could be said to the people who complain and demand the change in the first place. This article scream bias and hypocrisy.Yes, please sign me up for this webinar–and thank you
Hey there are using WordPress for your site platform? I’m new to the
blog world but I’m trying to get started and set up my own. Do
you require any coding knowledge to make your own blog? Any help would be
greatly appreciated!
Hi, Neat post. There is a problem along with your website in web
explorer, may test this? IE nonetheless is the marketplace leader and a good portion of
folks will miss your magnificent writing because of this problem.
Hello, Neat post. There is a problem with your website in internet explorer,
would test this? IE still is the marketplace chief
and a huge component to people will omit your great writing due to this problem.
my blog 사설토토사이트
Undeniably believe that which you said. Your favourite reason seemed to be on the net the easiest factor to take into
accout of. I say to you, I certainly get annoyed while other
people think about worries that they just don’t understand
about. You controlled to hit the nail upon the highest and also outlined out the whole thing without having side effect , other people can take a signal.
Will likely be back to get more. Thank you
Very good post. I’m dealing with many of these issues as well..
Great site you have got here.. It’s difficult to find excellent writing like yours these days.
I honestly appreciate individuals like you! Take care!!
Good day! I just would like to give you a big thumbs up
for your great info you’ve got here on this post.
I am coming back to your blog for more soon.
Hello! Do you know if they make any plugins to assist with SEO?
I’m trying to get my blog to rank for some targeted
keywords but I’m not seeing very good success. If you know of any please share.
Thank you!
I have been surfing online more than three hours today, yet I never found any interesting article
like yours. It’s pretty worth enough for me. Personally, if all site owners and bloggers made good content as you
did, the web will be much more useful than ever before.
Very nice post. I just stumbled upon your blog and wanted
to say that I have truly enjoyed surfing around your blog posts.
In any case I will be subscribing to your rss feed
and I hope you write again very soon!
Hello! Someone in my Myspace group shared this site with us
so I came to take a look. I’m definitely enjoying
the information. I’m book-marking and will be tweeting
this to my followers! Outstanding blog and terrific design and style.
Very nice post. I just stumbled upon your blog and wanted to say that I’ve really enjoyed browsing your blog posts. In any case I’ll be subscribing to your feed and I hope you write again soon!