Games numbers PHP

Prime number in PHP

A prime number is a natural number/whole number/cardinal number greater than 1 that has no positive divisors other than 1 and itself. A natural number greater than 1 that is not a prime number is called a composite number.
e.g. 2, 3, 5, 7, 11, 13, 17….etc are prime numbers; while 4, 6, 8, 9, 10, 12, 14, 15, 16….etc are composite numbers.

Program to determine if the supplied number is Prime or Composite using native bcmod() function.

$num = 26; // desired number to check
for ( $i = 2; $i <= $num - 1; $i++ ) {
    if ( bcmod( $num, $i ) == 0 ) {
        echo $num . " is composite number";
if ( $num == $i )
    echo $num . " is prime number";
'Coz sharing is caring

By Swatantra Kumar

Swatantra is an Open Source evangelist, a technologist and researcher. Professionally, he does software development, software architecture, server administration and project management. When he's not writing software, he enjoys building web entities and servers, reading about and working with new technologies, and trying to get his friends to make the move to open source software. He's written, co-written and published many articles in international journals, on various domains/topics including Open Source, Networks, Computer Organization, Mobile Technologies, and Business Intelligence. He made a proposal for an information management system at University level during graduation days.

One reply on “Prime number in PHP”

hello!,I like your writiong very a lot! proportion we krep up a corrwspondence more approximately your article on AOL?
I require ann expert onn this area to ssolve my problem.
Maybe that’s you! Looking forward to look you.

Feel free to surf to my weeb site:cheap echo of soul
gold online (Howard)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.