Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -12,7 +12,7 @@ F aks_test(p)
|
|||
R !any(ex[0 .< (len)-1].map(mult -> mult % @p != 0))
|
||||
|
||||
print(‘# p: (x-1)^p for small p’)
|
||||
L(p) 12
|
||||
L(p) 0.<12
|
||||
print(‘#3: #.’.format(p, enumerate(expand_x_1(p)).map((n, e) -> ‘#.#.#.’.format(‘+’ * (e >= 0), e, I n {(‘x^#.’.format(n))} E ‘’)).join(‘ ’)))
|
||||
|
||||
print("\n# small primes using the aks test")
|
||||
|
|
|
|||
|
|
@ -1,88 +0,0 @@
|
|||
with Ada.Text_IO;
|
||||
|
||||
procedure Test_For_Primes is
|
||||
|
||||
type Pascal_Triangle_Type is array (Natural range <>) of Long_Long_Integer;
|
||||
|
||||
function Calculate_Pascal_Triangle (N : in Natural) return Pascal_Triangle_Type is
|
||||
Pascal_Triangle : Pascal_Triangle_Type (0 .. N);
|
||||
begin
|
||||
Pascal_Triangle (0) := 1;
|
||||
for I in Pascal_Triangle'First .. Pascal_Triangle'Last - 1 loop
|
||||
Pascal_Triangle (1 + I) := 1;
|
||||
for J in reverse 1 .. I loop
|
||||
Pascal_Triangle (J) := Pascal_Triangle (J - 1) - Pascal_Triangle (J);
|
||||
end loop;
|
||||
Pascal_Triangle (0) := -Pascal_Triangle (0);
|
||||
end loop;
|
||||
return Pascal_Triangle;
|
||||
end Calculate_Pascal_Triangle;
|
||||
|
||||
function Is_Prime (N : Integer) return Boolean is
|
||||
I : Integer;
|
||||
Result : Boolean := True;
|
||||
Pascal_Triangle : constant Pascal_Triangle_Type := Calculate_Pascal_Triangle (N);
|
||||
begin
|
||||
I := N / 2;
|
||||
while Result and I > 1 loop
|
||||
Result := Result and Pascal_Triangle (I) mod Long_Long_Integer (N) = 0;
|
||||
I := I - 1;
|
||||
end loop;
|
||||
return Result;
|
||||
end Is_Prime;
|
||||
|
||||
function Image (N : in Long_Long_Integer;
|
||||
Sign : in Boolean := False) return String is
|
||||
Image : constant String := N'Image;
|
||||
begin
|
||||
if N < 0 then
|
||||
return Image;
|
||||
else
|
||||
if Sign then
|
||||
return "+" & Image (Image'First + 1 .. Image'Last);
|
||||
else
|
||||
return Image (Image'First + 1 .. Image'Last);
|
||||
end if;
|
||||
end if;
|
||||
end Image;
|
||||
|
||||
procedure Show (Triangle : in Pascal_Triangle_Type) is
|
||||
use Ada.Text_IO;
|
||||
Begin
|
||||
for I in reverse Triangle'Range loop
|
||||
Put (Image (Triangle (I), Sign => True));
|
||||
Put ("x^");
|
||||
Put (Image (Long_Long_Integer (I)));
|
||||
Put (" ");
|
||||
end loop;
|
||||
end Show;
|
||||
|
||||
procedure Show_Pascal_Triangles is
|
||||
use Ada.Text_IO;
|
||||
begin
|
||||
for N in 0 .. 9 loop
|
||||
declare
|
||||
Pascal_Triangle : constant Pascal_Triangle_Type := Calculate_Pascal_Triangle (N);
|
||||
begin
|
||||
Put ("(x-1)^" & Image (Long_Long_Integer (N)) & " = ");
|
||||
Show (Pascal_Triangle);
|
||||
New_Line;
|
||||
end;
|
||||
end loop;
|
||||
end Show_Pascal_Triangles;
|
||||
|
||||
procedure Show_Primes is
|
||||
use Ada.Text_IO;
|
||||
begin
|
||||
for N in 2 .. 63 loop
|
||||
if Is_Prime (N) then
|
||||
Put (N'Image);
|
||||
end if;
|
||||
end loop;
|
||||
New_Line;
|
||||
end Show_Primes;
|
||||
|
||||
begin
|
||||
Show_Pascal_Triangles;
|
||||
Show_Primes;
|
||||
end Test_For_Primes;
|
||||
|
|
@ -50,7 +50,7 @@ singleton AksTest
|
|||
}
|
||||
}
|
||||
|
||||
public program()
|
||||
public Program()
|
||||
{
|
||||
for (int n := 0; n < 10; n += 1) {
|
||||
AksTest.coef(n);
|
||||
|
|
|
|||
|
|
@ -1,84 +0,0 @@
|
|||
# AKS test for primes
|
||||
|
||||
$script:PasTriMax = 61 # for long type of Pascal triangle numbers
|
||||
|
||||
function Pascal-Triangle {
|
||||
# Calculate the n'th line 0.. middle
|
||||
param(
|
||||
[int]$N
|
||||
)
|
||||
|
||||
$pasTri = [long[]]::new([math]::Ceiling(($N + 2) / 2))
|
||||
$pasTri[0] = 1
|
||||
[int]$j = 1
|
||||
while ($j -le $N) {
|
||||
$j++
|
||||
[int]$k = [math]::Floor($j / 2)
|
||||
$pasTri[$k] = $pasTri[$k - 1]
|
||||
for (; $k -ge 1; $k--) {
|
||||
$pasTri[$k] += $pasTri[$k - 1]
|
||||
}
|
||||
}
|
||||
# Now: $j -eq ($N + 1), so $k -eq [math]::Floor(($N + 1) / 2)
|
||||
return $pasTri
|
||||
}
|
||||
|
||||
function Expand-Poly {
|
||||
param ([int]$N)
|
||||
|
||||
if ($N -gt $script:PasTriMax) {
|
||||
throw "$N is out of range"
|
||||
}
|
||||
switch($N) {
|
||||
0 {Write-Output "(x-1)^0 = 1"}
|
||||
1 {Write-Output "(x-1)^1 = x-1"}
|
||||
default {
|
||||
$VZ = @('+', '-')
|
||||
$pasTri = Pascal-Triangle($N)
|
||||
[string]$outTri = @()
|
||||
$outTri += "(x-1)^$N = x^$N"
|
||||
[bool]$bVz = $true
|
||||
[int]$nDiv2 = [math]::Floor($N / 2)
|
||||
for ([int]$j = $N - 1; $j -gt $nDiv2; $j--) {
|
||||
$outTri += "$($VZ[$bVz]) $($pasTri[$N - $j])*x^$j"
|
||||
$bVz = -not $bVz
|
||||
}
|
||||
for ([int]$j = $nDiv2; $j -gt 1; $j--) {
|
||||
$outTri += "$($VZ[$bVz]) $($pasTri[$j])*x^$j"
|
||||
$bVz = -not $bVz
|
||||
}
|
||||
$outTri += "$($VZ[$bVz]) $($pasTri[1])*x"
|
||||
$bVz = -not $bVz
|
||||
$outTri += "$($VZ[$bVz]) $($pasTri[0])"
|
||||
Write-Output $outTri
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Is-Prime {
|
||||
param([int]$N)
|
||||
|
||||
if ($N -gt $script:PasTriMax) {
|
||||
throw "$N is out of range"
|
||||
}
|
||||
$pasTri = Pascal-Triangle($N)
|
||||
[bool]$res = $true
|
||||
[int]$i = [math]::Floor($N / 2)
|
||||
while ($res -and ($i -gt 1)) {
|
||||
$res = $res -and ($pasTri[$i] % $N -eq 0)
|
||||
$i--
|
||||
}
|
||||
return $res
|
||||
}
|
||||
|
||||
# Test program
|
||||
foreach ($n in 0..9) {
|
||||
Expand-Poly($n)
|
||||
}
|
||||
[string]$primes = @()
|
||||
foreach ($n in 2..$script:PasTriMax) {
|
||||
if (Is-Prime($n)) {
|
||||
$primes += "{0,3}" -f $n
|
||||
}
|
||||
}
|
||||
Write-Output $primes
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
-- 28 Jul 2025
|
||||
include Settings
|
||||
-- 23 Aug 2025
|
||||
include Setting
|
||||
arg p
|
||||
if p = '' then
|
||||
p = 10
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue