Skip to main content

PrimeNumber

<?php
$submit=$_POST['submit'];
$prime=$_POST['n'];

//if($n===1){
//    echo"not a prime or composite no";
//}

if($prime==1){
    echo"not a prime or composite no";
}
for($index=2;$index<=$prime/2;$index++){
   
    if($prime%$index===0){
        $set=1;
    }
 
}
if($set){
    echo $prime." is a composite number";
}else{
    echo $prime." is a prime number";
}


?>

<form action="#" method="post" enctype="multipart/form-data">
   
    <table>
        <tr>
            <td><input type="text" name="n"></td>
            <td><input type="submit" name="submit" value="submit"></td>
        </tr>
    </table>
   
</form>

Comments

Popular posts from this blog

IDB HTML MCQ

Questions: 1. A webpage displays a picture. What tag was used to display that picture? a. picture b. image c. img d. src 2. <b> tag makes the enclosed text bold. What is other tag to make text bold? a. <strong> b. <dar> c. <black> d. <emp> 3. Tags and test that are not directly displayed on the page are written in _____ section. a. <html> b. <head> c. <title> d. <body> 4. Which tag inserts a line horizontally on your web page? a. <hr> b. <line> c. <line direction=”horizontal”> d. <tr> 5. What should be the first tag in any HTML document? a. <head> b. <title> c. <html> d. <document> 6. Which tag allows you to add a row in a table? a. <td> and </td> b. <cr> and </cr> c. <th> and </th> d. <tr> and </tr> 7. How can you make a bulleted list? a. <list> b. <nl> c. <ul> d. <ol> 8. Ho

Database Connection with PHP PDO MYSQL

PDO Connection MYSQLI // Create Connection with Pdo\ $dsn = "mysql:host=localhost; dbname=test;"; $db_user = "root"; $db_password = ""; try{     $conn = new PDO("$dsn", "$db_user","$db_password");    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);     // $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);     echo "Connected"; }catch(PDOException $a){     echo "Connection Failed". $a->getMessage(); }