PHP PROGRAM TO CHECK PRIME NUMBER OR NOT - STUDENTSBLOG100 PHP TUTORIAL - Anna University Internal marks 2018

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

12 comments:

  1. 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

    ReplyDelete
  2. 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

    ReplyDelete
  3. 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

    ReplyDelete
  4. 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

    ReplyDelete
  5. 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

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

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

    ReplyDelete
  8. 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

    ReplyDelete
  9. Thank you verrrrrrrrrrrrry much...

    ReplyDelete
  10. Excellent post. I was checking constantly this blog and I am
    impressed! Very helpful

    Real Estate Brokers in Chennai

    ReplyDelete