phpOMS/Math/Number/Numbers.php
Dennis Eichhorn 78bc28b045 Draft
All these files need further edits + other optimization files + moving
of files
2016-03-13 21:49:01 +01:00

28 lines
522 B
PHP

<?php
class Number
{
public static function perfect(int $n) : bool
{
$sum = 0;
for($i = 1; $i < $n; $i++) {
if($n % $i == 0) {
$sum += $i;
}
}
return $sum == $n;
}
public static function selfdescribing(int $n) : bool
{
foreach (str_split($n) as $place => $value) {
if (substr_count($number, $place) != $value) {
return false;
}
}
return true;
}
}