<?php
$n = (int)$_POST['n'];
$r = (int)$_POST['r'];
$model = $_POST['model'];
function factorial($n)
{
if($n == 0 or $n == 1)
{
return 1;
}
else
{
return($n * factorial($n-1));
}
}
// fungsi permutasi perulangan
function permutasi_perulangan($n, $r)
{
return(pow($n, $r));
}
// fungsi permutasi tak berulang
function permutasi_tak_berulang($n, $r)
{
return(factorial($n)/factorial($n-$r));
}
?>
<html>
<head>
<title>Fungsi Permutasi dengan PHP</title>
</head>
<body>
<center>
<form method="post">
<table cellpadding=5 cellspacing=2 border=1>
<tr>
<td>Permutasi</td>
<td>
<select name="model">
<option value="ulang">Permutasi Perulangan</option>
<option value="tidak">Permutasi Tak Berulang</option>
</select>
</td>
</tr>
<tr>
<td>N</td>
<td><input type=text name="n" size=5 value=<? echo $n; ?> /></td>
</tr>
<tr>
<td>M</td>
<td><input type=text name="r" size=5 value=<? echo $r; ?> /></td>
</tr>
<tr>
<td colspan=2 align=center><input type="submit" value="Permutasi" /></td>
</tr>
</table>
</form>
<?php
if(isset($n) && isset($r) && isset($model) && $n != 0 && $r != 0)
{
if($model == "ulang")
{
echo "<h2>$n<sup>$r</sup> = ";
echo permutasi_perulangan($n, $r);
echo "</h2>";
}
else
{
echo "<table border=0 cellpadding=0 cellspacing=0>";
echo "<tr><td align=center style=\"border-bottom: solid #000;\"><font size=6>$n!</font></td>";
echo "<td rowspan=2 valign=middle><font size=6> = ". permutasi_tak_berulang($n ,$r) ."</font>";
echo "</tr>";
echo "<tr><td align=center><font size=6>$r !($n - $r)!</font></td></tr></table>";
}
}
?>
</center>
</body>
</html>
- Output for 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- Warning: Undefined array key "n" in /in/V0qRW on line 2
Warning: Undefined array key "r" in /in/V0qRW on line 3
Warning: Undefined array key "model" in /in/V0qRW on line 4
<html>
<head>
<title>Fungsi Permutasi dengan PHP</title>
</head>
<body>
<center>
<form method="post">
<table cellpadding=5 cellspacing=2 border=1>
<tr>
<td>Permutasi</td>
<td>
<select name="model">
<option value="ulang">Permutasi Perulangan</option>
<option value="tidak">Permutasi Tak Berulang</option>
</select>
</td>
</tr>
<tr>
<td>N</td>
<td><input type=text name="n" size=5 value=<? echo $n; ?> /></td>
</tr>
<tr>
<td>M</td>
<td><input type=text name="r" size=5 value=<? echo $r; ?> /></td>
</tr>
<tr>
<td colspan=2 align=center><input type="submit" value="Permutasi" /></td>
</tr>
</table>
</form>
</center>
</body>
</html>
- Output for 8.0.13
- Warning: Undefined array key "n" in /in/V0qRW on line 2
Warning: Undefined array key "r" in /in/V0qRW on line 3
Warning: Undefined array key "model" in /in/V0qRW on line 4
<html>
<head>
<title>Fungsi Permutasi dengan PHP</title>
</head>
<body>
<center>
<form method="post">
<table cellpadding=5 cellspacing=2 border=1>
<tr>
<td>Permutasi</td>
<td>
<select name="model">
<option value="ulang">Permutasi Perulangan</option>
<option value="tidak">Permutasi Tak Berulang</option>
</select>
</td>
</tr>
<tr>
<td>N</td>
<td><input type=text name="n" size=5 value=0 /></td>
</tr>
<tr>
<td>M</td>
<td><input type=text name="r" size=5 value=0 /></td>
</tr>
<tr>
<td colspan=2 align=center><input type="submit" value="Permutasi" /></td>
</tr>
</table>
</form>
</center>
</body>
</html>
- Output for 5.4.0 - 5.4.45, 7.4.33
- Notice: Undefined index: n in /in/V0qRW on line 2
Notice: Undefined index: r in /in/V0qRW on line 3
Notice: Undefined index: model in /in/V0qRW on line 4
<html>
<head>
<title>Fungsi Permutasi dengan PHP</title>
</head>
<body>
<center>
<form method="post">
<table cellpadding=5 cellspacing=2 border=1>
<tr>
<td>Permutasi</td>
<td>
<select name="model">
<option value="ulang">Permutasi Perulangan</option>
<option value="tidak">Permutasi Tak Berulang</option>
</select>
</td>
</tr>
<tr>
<td>N</td>
<td><input type=text name="n" size=5 value=0 /></td>
</tr>
<tr>
<td>M</td>
<td><input type=text name="r" size=5 value=0 /></td>
</tr>
<tr>
<td colspan=2 align=center><input type="submit" value="Permutasi" /></td>
</tr>
</table>
</form>
</center>
</body>
</html>
- Output for 5.3.0 - 5.3.29, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.32
- Notice: Undefined index: n in /in/V0qRW on line 2
Notice: Undefined index: r in /in/V0qRW on line 3
Notice: Undefined index: model in /in/V0qRW on line 4
<html>
<head>
<title>Fungsi Permutasi dengan PHP</title>
</head>
<body>
<center>
<form method="post">
<table cellpadding=5 cellspacing=2 border=1>
<tr>
<td>Permutasi</td>
<td>
<select name="model">
<option value="ulang">Permutasi Perulangan</option>
<option value="tidak">Permutasi Tak Berulang</option>
</select>
</td>
</tr>
<tr>
<td>N</td>
<td><input type=text name="n" size=5 value=<? echo $n; ?> /></td>
</tr>
<tr>
<td>M</td>
<td><input type=text name="r" size=5 value=<? echo $r; ?> /></td>
</tr>
<tr>
<td colspan=2 align=center><input type="submit" value="Permutasi" /></td>
</tr>
</table>
</form>
</center>
</body>
</html>
- Output for 7.3.32 - 7.3.33
- <html>
<head>
<title>Fungsi Permutasi dengan PHP</title>
</head>
<body>
<center>
<form method="post">
<table cellpadding=5 cellspacing=2 border=1>
<tr>
<td>Permutasi</td>
<td>
<select name="model">
<option value="ulang">Permutasi Perulangan</option>
<option value="tidak">Permutasi Tak Berulang</option>
</select>
</td>
</tr>
<tr>
<td>N</td>
<td><input type=text name="n" size=5 value=0 /></td>
</tr>
<tr>
<td>M</td>
<td><input type=text name="r" size=5 value=0 /></td>
</tr>
<tr>
<td colspan=2 align=center><input type="submit" value="Permutasi" /></td>
</tr>
</table>
</form>
</center>
</body>
</html>
- Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
- Notice: Undefined index: n in /in/V0qRW on line 2
Notice: Undefined index: r in /in/V0qRW on line 3
Notice: Undefined index: model in /in/V0qRW on line 4
<html>
<head>
<title>Fungsi Permutasi dengan PHP</title>
</head>
<body>
<center>
<form method="post">
<table cellpadding=5 cellspacing=2 border=1>
<tr>
<td>Permutasi</td>
<td>
<select name="model">
<option value="ulang">Permutasi Perulangan</option>
<option value="tidak">Permutasi Tak Berulang</option>
</select>
</td>
</tr>
<tr>
<td>N</td>
<td><input type=text name="n" size=5 value=<? echo $n; ?> /></td>
</tr>
<tr>
<td>M</td>
<td><input type=text name="r" size=5 value=<? echo $r; ?> /></td>
</tr>
<tr>
<td colspan=2 align=center><input type="submit" value="Permutasi" /></td>
</tr>
</table>
</form>
</center>
</body>
</html>
preferences:
295.88 ms | 404 KiB | 459 Q