Skip to main content

PHP program to check whether a number is prime or not

 Php:

<?php

function isPrime($num) {

    if ($num < 2) {

        return false;

    }

    for ($i = 2; $i <= sqrt($num); $i++) {

        if ($num % $i === 0) {

            return false;

        }

    }

    return true;

}


// Test the function with numbers from 1 to 50

for ($i = 1; $i <= 50; $i++) {

    if (isPrime($i)) {

        echo $i . " is prime.\n";

    }

}

?>

Html 1:

<!DOCTYPE html>
<html>
<head>
    <title>HTML with PHP</title>
</head>
<body>

    <h1>PHP program print prime number</h1>

    <?php
function isPrime($num) {
    if ($num < 2) {
        return false;
     }
    for ($i = 2; $i <= sqrt($num); $i++) {
         if ($num % $i === 0) {
            return false;
        }
    }
    return true;
}

// Test the function with numbers from 1 to 50
for ($i = 1; $i <= 50; $i++) {
     if (isPrime($i)) {
        echo $i . " is prime.\n";
    }
}
?>


</body>
</html>


Html 2:

<!DOCTYPE html>
<html>
<head>
    <title>HTML with PHP</title>
</head>
<body>

    <h1>PHP program print prime number</h1>

    <?php
function isPrime($num) {
    if ($num < 2) {
        return false;
     }
    for ($i = 2; $i <= sqrt($num); $i++) {
         if ($num % $i === 0) {
            return false;
        }
    }
    return true;
}

// Test the function with numbers from 1 to 50
for ($i = 1; $i <= 50; $i++) {
     if (isPrime($i)) {
        echo $i . " is prime.\n";
    }
}
?>
<p>The Prime Numbers Upto 50</p>
<p>2 is prime.</p>
<p>3 is prime.</p>
<p>5 is prime.</p>
<p>7 is prime.</p>
<p>11 is prime.</p>
<p>13 is prime.</p>
<p>17 is prime.</p>
<p>19 is prime.</p>
<p>23 is prime.</p>
<p>29 is prime.</p>
<p>31 is prime.</p>
<p>37 is prime.</p>
<p>41 is prime.</p>
<p>43 is prime.</p>
<p>47 is prime.</p>


</body>
</html>


Comments

Popular posts from this blog

Stable Diffusion WebUI 1.10.1 Full Installation Guide | AUTOMATIC1111 | Windows 11

Stable Diffusion WebUI 1.10.1 Full Installation Guide | AUTOMATIC1111 | Windows 11  Welcome to this step-by-step Stable Diffusion WebUI 1.10.1 installation guide! In this tutorial, we will walk you through the complete setup process on Windows 11 , including downloading and installing Git , setting up Python 3.10.6 , cloning the AUTOMATIC1111 repository , and configuring .gitignore for a clean and efficient installation. By following this guide, you’ll be able to generate AI-generated images using Stable Diffusion with ease. Whether you're new to AI image generation or an experienced user, this guide ensures that your setup is optimized for performance and stability. 🔗 Required Downloads: Before we begin, make sure to download the following tools: ✅ Git for Windows – Download Here ✅ Stable Diffusion WebUI (AUTOMATIC1111) – Download Here ✅ Python 3.10.6 – Download Here 🛠️ Step-by-Step Installation Process 1️⃣ Install Git for Windows Git is required to clone the ...

Unreal Engine Product Showcase: Mesmerizing Video Sequence Render

  4k Image:

Install TensorFlow on Windows 11: Step-by-Step Guide for CPU & GPU

 --- Installing **TensorFlow on Windows 11** requires setting up system dependencies, configuring Python, and ensuring compatibility with CPU or GPU acceleration. This step-by-step guide provides everything needed to install **TensorFlow 2.10 or lower** on **Windows Native**, including software prerequisites, Microsoft Visual C++ Redistributable installation, Miniconda setup, GPU driver configuration, and verification steps.   ### **System Requirements:**   Before installing TensorFlow, ensure your system meets these requirements:   - **Operating System:** Windows 7 or higher (64-bit)   - **Python Version:** 3.9–3.12   - **pip Version:** 19.0 or higher for Linux and Windows, 20.3 or higher for macOS   - **Microsoft Visual C++ Redistributable:** Required for Windows Native   - **Long Paths Enabled:** Ensure long paths are enabled in Windows settings   For **GPU support**, install:   - **NVIDIA ...