Berechnet die Quersumme einer belibigen Zahl.
<?php
function quersumme($zahl) {
settype($zahl, "string");
$res = 0;
for($i=0; $i<strlen($zahl); $i++) {
$res = $res + $zahl[$i];
}
return $res;
}
?>
Tags: Funktion, PHP, Quersumme
This entry was posted on Dezember 21st, 2010
and is filed under Zahlen und Mathe.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response or Trackback from your own site.