This should be a good start. You can probablly make it faster but this is a quick working thing.
Input:
<HTML>
<HEAD>
<TITLE>.:Math problem:.</TITLE>
<style>
#buttonWit{
background-color:#ffffff;
border-color:Black;
border-style:solid;
font-family:Verdana;
border-width = 1px;
}
</style>
</HEAD>
<BODY topmargin="0" leftmargin="0" rightmargin="0" >
<table width="100%" id="topTable">
<br>
<table width=80%>
<tr>
<td id="InfoH" colspan=2>Please submit your variables.
</tr>
<tr>
<td colspan = 2> </td>
</tr>
<FORM ACTION="math.php" METHOD="POST" name="math">
<tr>
<td>
P:
</td>
<td>
<input type="text" name="p" id="buttonWit">
</td>
</tr>
<tr>
<td>
Q:
</td>
<td>
<input type="text" name="q" id="buttonWit">
</td>
</tr>
<tr>
<td colspan=2>
<INPUT TYPE="submit" NAME="Submit" VALUE="GO!!" id="buttonWit">
</td>
</tr>
</form>
</table>
</body>
</html>
Math.php
<?
$pq = ($p-1)*($q-1);
$x = 1;
$i = 2;
$j = 2;
while(!isset($e)&&!isset($d)){
$temp = $i * $j;
$temp2 = ($pq * $x) + 1;
//echo "<script>alert('$temp == $temp2')</script>";
if($temp == $temp2){
$e = $i;
$d = $j;
}else{
if($temp < $temp2){
if($i < $j){
$i += 1;
}else{
$j += 1;
}
}else{
if($i > $temp2 || $j > $temp2){
$x += 1;
$i = 2;
$j = 2;
}else{
$i = 2;
$j += 1;
}
}
}
}
echo "e * d - 1 == (p-1)*(q-1)*x";
echo "<br><br>";
echo "Where: <br><br>";
echo "e : $e<br>";
echo "d : $d<br>";
echo "x : $x<br>";
echo "p : $p<br>";
echo "q: $q<br><br>";
echo "$e * $d - 1 == ($p-1)*($q-1)*$x<br>";
echo "= $temp";
?>
I tested it with these numbers:
p : 6854
q: 456
And it printed out:
e d - 1 == (p-1)(q-1)*x
Where:
e : 1319
d : 2364
x : 1
p : 6854
q: 456
1319 2364 - 1 == (6854-1)(456-1)*1
= 3118116