Data update
This commit is contained in:
parent
72eb4943cb
commit
4d5544505c
2347 changed files with 62432 additions and 16731 deletions
29
Task/M-bius-function/PHP/m-bius-function.php
Normal file
29
Task/M-bius-function/PHP/m-bius-function.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
// Moebius function
|
||||
|
||||
function moebius($n) {
|
||||
$m = 1;
|
||||
if ($n != 1) {
|
||||
$f = 2;
|
||||
do {
|
||||
if ($n % ($f * $f) == 0) {
|
||||
$m = 0;
|
||||
} else {
|
||||
if ($n % $f == 0) {
|
||||
$m = -$m;
|
||||
$n /= $f;
|
||||
}
|
||||
$f++;
|
||||
}
|
||||
} while ($f <= $n && $m != 0);
|
||||
}
|
||||
return $m;
|
||||
}
|
||||
|
||||
for ($t = 0; $t <= 9; $t++) {
|
||||
for ($u = 1; $u <= 10; $u++) {
|
||||
echo str_pad(moebius(10 * $t + $u), 2, " ", STR_PAD_LEFT)." ";
|
||||
}
|
||||
echo PHP_EOL;
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue