Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
39
Task/M-bius-function/Ada/m-bius-function.adb
Normal file
39
Task/M-bius-function/Ada/m-bius-function.adb
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
with Strings_Edit.Integers; use Strings_Edit.Integers;
|
||||
with Unbounded_Unsigneds; use Unbounded_Unsigneds;
|
||||
with Unbounded_Unsigneds.Primes; use Unbounded_Unsigneds.Primes;
|
||||
|
||||
procedure Moebius is
|
||||
function Moebius (N : Half_Word) return Integer is
|
||||
Prime : Unbounded_Unsigned := One;
|
||||
Value : Half_Word := N;
|
||||
Factor : Half_Word;
|
||||
Result : Integer := 1;
|
||||
begin
|
||||
while Value > 1 loop
|
||||
Next_Prime (Prime, 15);
|
||||
Factor := To_Half_Word (Prime);
|
||||
if Value mod Factor = 0 then
|
||||
Value := Value / Factor;
|
||||
if Value mod Factor = 0 then
|
||||
return 0;
|
||||
end if;
|
||||
Result := -Result;
|
||||
end if;
|
||||
end loop;
|
||||
return Result;
|
||||
end Moebius;
|
||||
Line : String (1..80);
|
||||
Pointer : Integer := 1;
|
||||
begin
|
||||
for N in Half_Word range 1..199 loop
|
||||
Put (Line, Pointer, Moebius (N), 10, True, 3, Strings_Edit.Right);
|
||||
if Pointer > 68 then
|
||||
Put_Line (Line (1..Pointer - 1));
|
||||
Pointer := 1;
|
||||
end if;
|
||||
end loop;
|
||||
if Pointer > 1 then
|
||||
Put_Line (Line (1..Pointer - 1));
|
||||
end if;
|
||||
end Moebius;
|
||||
38
Task/M-bius-function/Loglan82/m-bius-function.loglan82
Normal file
38
Task/M-bius-function/Loglan82/m-bius-function.loglan82
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
(* Moebius function *)
|
||||
|
||||
block
|
||||
|
||||
unit Moebius: function (n: integer): integer;
|
||||
var
|
||||
m, f: integer;
|
||||
begin
|
||||
m := 1;
|
||||
if n =/= 1
|
||||
then
|
||||
f := 2;
|
||||
do
|
||||
if n mod (f * f) = 0
|
||||
then m := 0
|
||||
else
|
||||
if n mod f = 0
|
||||
then
|
||||
m := -m;
|
||||
n := n div f
|
||||
fi;
|
||||
f := f + 1
|
||||
fi;
|
||||
if (f > n) or (m = 0) then exit fi
|
||||
od
|
||||
fi;
|
||||
result := m
|
||||
end;
|
||||
|
||||
var
|
||||
t, u: integer;
|
||||
begin
|
||||
for t := 0 to 9
|
||||
do
|
||||
for u := 1 to 10 do write(Moebius(10 * t + u): 2, " ") od;
|
||||
writeln;
|
||||
od;
|
||||
end;
|
||||
28
Task/M-bius-function/PowerShell/m-bius-function.ps1
Normal file
28
Task/M-bius-function/PowerShell/m-bius-function.ps1
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# Moebius function
|
||||
|
||||
function Moebius([int]$N) {
|
||||
[int]$m = 1
|
||||
if ($N -ne 1) {
|
||||
[int]$f = 2
|
||||
do {
|
||||
if ($N % ($f * $f) -eq 0) {
|
||||
$m = 0
|
||||
} else {
|
||||
if ($N % $f -eq 0) {
|
||||
$m = -$m;
|
||||
$N = [math]::Floor($N / $f)
|
||||
}
|
||||
$f += 1
|
||||
}
|
||||
} while (($f -le $N) -and ($m -ne 0))
|
||||
}
|
||||
return $m
|
||||
}
|
||||
|
||||
foreach ($t in 0..9) {
|
||||
[string]$row = @()
|
||||
foreach ($u in 1..10) {
|
||||
$row += "{0,2} " -f $(Moebius(10 * $t + $u))
|
||||
}
|
||||
Write-Output $row
|
||||
}
|
||||
28
Task/M-bius-function/QuickBASIC/m-bius-function.basic
Normal file
28
Task/M-bius-function/QuickBASIC/m-bius-function.basic
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
' Moebius function
|
||||
DECLARE FUNCTION Moebius% (N%)
|
||||
FOR T% = 0 TO 9
|
||||
FOR U% = 1 TO 10
|
||||
PRINT USING "## "; Moebius%(10 * T% + U%);
|
||||
NEXT U%
|
||||
PRINT
|
||||
NEXT T%
|
||||
END
|
||||
|
||||
FUNCTION Moebius% (N%)
|
||||
M% = 1
|
||||
IF N% <> 1 THEN
|
||||
F% = 2
|
||||
DO
|
||||
IF (N% MOD (F% * F%)) = 0 THEN
|
||||
M% = 0
|
||||
ELSE
|
||||
IF N% MOD F% = 0 THEN
|
||||
M% = -M%
|
||||
N% = N% \ F%
|
||||
END IF
|
||||
F% = F% + 1
|
||||
END IF
|
||||
LOOP WHILE (F% <= N%) AND (M% <> 0)
|
||||
END IF
|
||||
Moebius% = M%
|
||||
END FUNCTION
|
||||
3
Task/M-bius-function/Uiua/m-bius-function.uiua
Normal file
3
Task/M-bius-function/Uiua/m-bius-function.uiua
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# e.g. 12 -> [2 2 3] -> [2 1] -> [0 1] -> [0 ¯1] -> 0
|
||||
Moeb ← +0/ׯ≤1⊕⧻⊸⊛°/×
|
||||
↯∞_10≡Moeb↘1⇡101
|
||||
41
Task/M-bius-function/VBA/m-bius-function.vba
Normal file
41
Task/M-bius-function/VBA/m-bius-function.vba
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
' Moebius function
|
||||
|
||||
Public Sub MainMoebius()
|
||||
Dim T, U As Integer
|
||||
For T = 0 To 9
|
||||
For U = 1 To 10
|
||||
Debug.Print FormatInteger(Moebius(10 * T + U), 2); " ";
|
||||
Next U
|
||||
Debug.Print
|
||||
Next T
|
||||
End Sub
|
||||
|
||||
Function FormatInteger(Num As Integer, L As Integer) As String
|
||||
Dim S As String
|
||||
S = LTrim(RTrim(Str(Num)))
|
||||
If Len(S) > L Then
|
||||
FormatInteger = String(L, "#")
|
||||
Else
|
||||
FormatInteger = Right(String(L, " ") & S, L)
|
||||
End If
|
||||
End Function
|
||||
|
||||
Function Moebius(N As Integer) As Integer
|
||||
Dim M, F As Integer
|
||||
M = 1
|
||||
If N <> 1 Then
|
||||
F = 2
|
||||
Do
|
||||
If (N Mod (F * F)) = 0 Then
|
||||
M = 0
|
||||
Else
|
||||
If N Mod F = 0 Then
|
||||
M = -M
|
||||
N = N \ F
|
||||
End If
|
||||
F = F + 1
|
||||
End If
|
||||
Loop While (F <= N) And (M <> 0)
|
||||
End If
|
||||
Moebius = M
|
||||
End Function
|
||||
Loading…
Add table
Add a link
Reference in a new issue