Skip to main content

Factorial Fibinicci

Factorial

<center>
<form action = "" method="post">
    <h2>Factorial Number</h2>
    <table>
        <tr><td><input type="number" name="aa" /></td></tr>
        <tr><td><input type="submit" name="save" value="Submit" /></td></tr>
       
</table>
</form>
</center>
<?php
$x=$_POST['save'];
$y=$_POST['aa'];
function getFactorial($y){
    $fact=1;
    for($i=1;$i<=$y;$i++)
        $fact *=$i;
    return $fact;
   
   
}
if(isset($x)and($y))
    {
    echo 'Factorial of Number  : <strong>'.  getFactorial($y).'</strong>';
}

?>

Fibinicci

<?php
$a=0;
$b=1;

for($i=0;$i<=10;$i++){
    if($i==0){
        $c=0;
    }else{
       
        $c=$a+$b;
        $a=$b;
        $b=$c;
    }
   
    echo $c." ";
}


?>

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(); }