mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
All these files need further edits + other optimization files + moving of files
28 lines
522 B
PHP
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;
|
|
}
|
|
} |