google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.: Write a php program to check wether a number is prime or not

Monday, April 6, 2020

Write a php program to check wether a number is prime or not

Write a php program to check wether a number is prime or not 

<?php 
// PHP code to check wether a number is prime or Not

function primeCheck($number)

    if ($number == 1) 

    return 0; 

    for ($i = 2; $i <= $number/2; $i++)

        if ($number % $i == 0) 

            return 0; 

    } 

    return 1; 

  
$number = 31; 

$flag = primeCheck($number); 

if ($flag == 1) 

    echo "Prime number"; 
else

    echo "Not Prime number"
?>

No comments:

Post a Comment

अच्छे विचार करे विचार

  पहचान की नुमाईश, जरा कम करें... जहाँ भी "मैं" लिखा है, उसे "हम" करें... हमारी "इच्छाओं" से ज़्यादा "सुन...