Hello Stefan,
und hier der letzte gefunde Versuch für die Iteration
<?php ### ratenrechnung.php ###
$kapital = 30000;
$zins = 0.085;
$anzahl = 36;
#------------------------------------------------------------------------------
function get_rest($kapital, $zins, $rate, $anzahl)
{
$restwert = $kapital;
for ($i=$anzahl; $i>0; $i--)
{
$restwert = round(($restwert * (1+$zins/12) - $rate),2);
}
return $restwert;
}
#------------------------------------------------------------------------------
$rate = $kapital * (1+$anzahl*$zins/12)/$anzahl;
echo"
<style type="text/css">
<!--
.num
{
text-align:right;
}
-->
</style>\n";
echo "
<table border="1">
<tr>
<td>Schritt</td>
<td>Rate</td>
<td>Rest</td>
<td>Faktor</td>
</tr>\n";
$count = 0;
$faktor = 0.0;
while ((abs($faktor - 1) > 0.000001) and ++$count <= 30)
{
$rest = get_rest($kapital, $zins, $rate, $anzahl);
#$faktor = sqrt($kapital/($kapital-$rest));
$faktor = ($kapital/($kapital-$rest));
echo "
<tr>
<td class="num"> $count </td>
<td class="num"> $rate </td>
<td class="num"> $rest </td>
<td class="num"> $faktor </td>
</tr>\n";
$rate = $rate * $faktor;
}
echo "
</table>\n";
?>
Harzliche Grüße aus http://www.annerschbarrich.de
Tom
Fortschritt entsteht nur durch die Auseinandersetzung der Kreativen
Nur selber lernen macht schlau