PHP PROGRAM TO CHECK PRIME NUMBER OR NOT - STUDENTSBLOG100 PHP TUTORIAL


Logic is same for all programs and only programming statements are different. Here we have given php programming logic to find given number is prime or not.

What is prime Number:
  • A Prime Number can be divided evenly only by 1, or itself. 
  • For example : 5 can only be divided by 1 or 5, so it is a prime number. 
  • But 6 can be divided by 1, 2, 3 and 6 so it is NOT a prime number.
Prime Number Programming Logic:
  • We should do modulo operation for the input number from 1 to input number. ie) 3 % 1 == 0 , 3 % 2 == 1 and 3 % 3 == 0. 
  • Each and every prime number will get two '0' modulo result.
  • So, each time when modulo result occurs 0, increment the count variable, ie) count++
  • After that check the condition that, if count variable == 2, input number is prime else not a prime number
Prime Number PHP program:
Output:
3 is a Prime number

Click Here to get -- > Php Tutorials by Studentsblog100

Previous
Next Post »

9 comments

Click here for comments
karthik anu
admin
7 March 2017 at 12:33 ×

Nice it seems to be good post... It will get readers engagement on the article since readres engagement plays an vital role in every blog.. i am expecting more updated posts from your hands.
iOS Training in Chennai
Android Training in Chennai
php Training in Chennai

Reply
avatar
john stany
admin
9 June 2017 at 12:34 ×

I am expecting more interesting topics from you. And this was nice content and definitely it will be useful for many people.
Android App Development Company

Reply
avatar
Sharon Sandy
admin
24 June 2017 at 11:46 ×

great and nice blog thanks sharing..I just want to say that all the information you have given here is awesome...Thank you very much for this one.
web design Company
web development Company
web design Company in chennai
web development Company in chennai
web design Company in India
web development Company in India

Reply
avatar
Sharon Sandy
admin
27 June 2017 at 11:06 ×

great and nice blog thanks sharing..I just want to say that all the information you have given here is awesome...Thank you very much for this one.
web design Company
web development Company
web design Company in chennai
web development Company in chennai
web design Company in India
web development Company in India

Reply
avatar
john stany
admin
30 June 2017 at 18:52 ×

Being new to the blogging world I feel like there is still so much to learn. Your tips helped to clarify a few things for me as well iOS App Development Company
iOS App Development Company

Reply
avatar
3 July 2017 at 20:27 ×

it is really amazing...thanks for sharing....provide more useful information...
Mobile app development company

Reply
avatar
5 July 2017 at 11:32 ×

it is really amazing...thanks for sharing....provide more useful information...
Mobile app development company

Reply
avatar
louis philip
admin
1 August 2017 at 19:38 ×

You have provided an nice article, Thank you very much for this one. And i hope this will be useful for many people.. and i am waiting for your next post keep on updating these kinds of knowledgeable things...
Fitness SMS
Fitness Text
Salon SMS
Salon Text
Investor Relation SMS
Investor Relation Text

Reply
avatar
Unknown
admin
28 November 2017 at 20:17 ×

Thank you verrrrrrrrrrrrry much...

Reply
avatar