Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -10,8 +10,8 @@ COMMENT
BEGIN
INT tf := 2, residue := n, count := 1;
WHILE tf < residue DO
INT remainder = residue MOD tf;
( remainder = 0 | count +:= 1; residue %:= tf | tf +:= 1 )
INT remainder = residue MOD tf;
( remainder = 0 | count +:= 1; residue %:= tf | tf +:= 1 )
OD;
count
END;
@ -25,8 +25,8 @@ COMMENT
INT k := num facs(i);
IF k <= classes
THEN
INT c = 1 + count OF table[k];
( c <= examples | (data OF table[k])[c] := i; count OF table[k] := c )
INT c = 1 + count OF table[k];
( c <= examples | (data OF table[k])[c] := i; count OF table[k] := c )
FI;
INT sum := 0;
FOR i TO classes DO sum +:= count OF table[i] OD;

View file

@ -1,25 +0,0 @@
with Prime_Numbers, Ada.Text_IO;
procedure Test_Kth_Prime is
package Integer_Numbers is new
Prime_Numbers (Natural, 0, 1, 2);
use Integer_Numbers;
Out_Length: constant Positive := 10; -- 10 k-th almost primes
N: Positive; -- the "current number" to be checked
begin
for K in 1 .. 5 loop
Ada.Text_IO.Put("K =" & Integer'Image(K) &": ");
N := 2;
for I in 1 .. Out_Length loop
while Decompose(N)'Length /= K loop
N := N + 1;
end loop; -- now N is Kth almost prime;
Ada.Text_IO.Put(Integer'Image(Integer(N)));
N := N + 1;
end loop;
Ada.Text_IO.New_Line;
end loop;
end Test_Kth_Prime;

View file

@ -1,27 +1,5 @@
almostPrime: function [k, listLen][
result: new []
test: 2
c: 0
while [c < listLen][
i: 2
m: 0
n: test
while [i =< n][
if? zero? n % i [
n: n / i
m: m + 1
]
else -> i: i + 1
]
if m = k [
'result ++ test
c: c + 1
]
test: test + 1
]
return result
select.first: listLen 1..infinite 'n [k = size factors.prime n]
]
loop 1..5 'x ->

View file

@ -1,69 +0,0 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. ALMOST-PRIME.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 CONTROL-VARS.
03 K PIC 9.
03 I PIC 999.
03 SEEN PIC 99.
03 N PIC 999.
03 P PIC 99.
03 P-SQUARED PIC 9(4).
03 F PIC 99.
03 N-DIV-P PIC 999V999.
03 FILLER REDEFINES N-DIV-P.
05 NEXT-N PIC 999.
05 FILLER PIC 999.
88 N-DIVS-P VALUE ZERO.
01 OUT-VARS.
03 K-LN PIC X(70).
03 K-LN-PTR PIC 99.
03 LN-HDR.
05 FILLER PIC X(4) VALUE "K = ".
05 K-OUT PIC 9.
05 FILLER PIC X VALUE ":".
03 I-FMT.
05 FILLER PIC X VALUE SPACE.
05 I-OUT PIC ZZ9.
PROCEDURE DIVISION.
BEGIN.
PERFORM K-ALMOST-PRIMES VARYING K FROM 1 BY 1
UNTIL K IS GREATER THAN 5.
STOP RUN.
K-ALMOST-PRIMES.
MOVE SPACES TO K-LN.
MOVE 1 TO K-LN-PTR.
MOVE ZERO TO SEEN.
MOVE K TO K-OUT.
STRING LN-HDR DELIMITED BY SIZE INTO K-LN
WITH POINTER K-LN-PTR.
PERFORM I-K-ALMOST-PRIME VARYING I FROM 2 BY 1
UNTIL SEEN IS EQUAL TO 10.
DISPLAY K-LN.
I-K-ALMOST-PRIME.
MOVE ZERO TO F, P-SQUARED.
MOVE I TO N.
PERFORM PRIME-FACTOR VARYING P FROM 2 BY 1
UNTIL F IS NOT LESS THAN K
OR P-SQUARED IS GREATER THAN N.
IF N IS GREATER THAN 1, ADD 1 TO F.
IF F IS EQUAL TO K,
MOVE I TO I-OUT,
ADD 1 TO SEEN,
STRING I-FMT DELIMITED BY SIZE INTO K-LN
WITH POINTER K-LN-PTR.
PRIME-FACTOR.
MULTIPLY P BY P GIVING P-SQUARED.
DIVIDE N BY P GIVING N-DIV-P.
PERFORM DIVIDE-FACTOR UNTIL NOT N-DIVS-P.
DIVIDE-FACTOR.
MOVE NEXT-N TO N.
ADD 1 TO F.
DIVIDE N BY P GIVING N-DIV-P.

View file

@ -1,32 +1,28 @@
local fn K_Prime( n as long, k as long ) as BOOL
long f = 0, i = 0
BOOL result
local fn almostPrimes
uint8 i = 1, primes( 50 ) = {2,3,5,7,11,13,17,19,23,29,31,¬
37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,¬
131,137,139,149,151,157,163,167,173,179,109,113,127}
for i = 2 to n
while ( n mod i == 0 )
if f = k then exit fn = NO
f += 1
n /= i
while 10 > mda_count 5 // Quit when k=5 list is filled
int k = 0, x = 0, n = i
while n > 1
if (n % primes(x)) then x++ else k++ : n /= primes(x)
wend
next
result = f = k
end fn = result
long i, c, k
for k = 1 to 5
printf @"k = %ld:\b", k
i = 2
c = 0
while ( c < 10 )
if ( fn K_Prime( i, k ) )
printf @"%4ld\b", i
c++
end if
mda_add k = i
i++
wend
print
end fn
window 1, @"Almost primes"
fn almostPrimes
printf @" Almost primes from 2 to %d with k prime factors:", mda_integer 5 (9)
for int k = 1 to 5
printf @"\n k=%d:\b",k
for int i = 0 to 9
printf @"%5d\b", mda_integer k ( i )
next
printf @" + %2d more.", (mda_count k) - 10
next
HandleEvents

View file

@ -1,16 +1,15 @@
(phixonline)-->
<span style="color: #004080;">sequence</span> <span style="color: #000000;">res</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">columnize</span><span style="color: #0000FF;">({</span><span style="color: #7060A8;">tagset</span><span style="color: #0000FF;">(</span><span style="color: #000000;">5</span><span style="color: #0000FF;">)})</span> <span style="color: #000080;font-style:italic;">-- ie {{1},{2},{3},{4},{5}}</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">n</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">2</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">found</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">0</span>
<span style="color: #008080;">while</span> <span style="color: #000000;">found</span><span style="color: #0000FF;"><</span><span style="color: #000000;">50</span> <span style="color: #008080;">do</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">l</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">prime_factors</span><span style="color: #0000FF;">(</span><span style="color: #000000;">n</span><span style="color: #0000FF;">,</span><span style="color: #004600;">true</span><span style="color: #0000FF;">))</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">l</span><span style="color: #0000FF;"><=</span><span style="color: #000000;">5</span> <span style="color: #008080;">and</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">res</span><span style="color: #0000FF;">[</span><span style="color: #000000;">l</span><span style="color: #0000FF;">])<=</span><span style="color: #000000;">10</span> <span style="color: #008080;">then</span>
<span style="color: #000000;">res</span><span style="color: #0000FF;">[</span><span style="color: #000000;">l</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">&=</span> <span style="color: #000000;">n</span>
<span style="color: #000000;">found</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">1</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #000000;">n</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">1</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span>
<span style="color: #004080;">string</span> <span style="color: #000000;">fmt</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"k = %d: "</span><span style="color: #0000FF;">&</span><span style="color: #7060A8;">join</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"%4d"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">10</span><span style="color: #0000FF;">))&</span><span style="color: #008000;">"\n"</span>
<span style="color: #008080;">for</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #000000;">5</span> <span style="color: #008080;">do</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">fmt</span><span style="color: #0000FF;">,</span><span style="color: #000000;">res</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">])</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<!--
with javascript_semantics
sequence res = columnize({tagset(5)}) -- ie {{1},{2},{3},{4},{5}}
integer n = 2, found = 0
while found<50 do
integer l = length(prime_factors(n,true))
if l<=5 and length(res[l])<=10 then
res[l] &= n
found += 1
end if
n += 1
end while
string fmt = "k = %d: "&join(repeat("%4d",10))&"\n"
for i=1 to 5 do
printf(1,fmt,res[i])
end for

View file

@ -16,7 +16,7 @@ local function gen(k, n)
for i = 1, n do
while !k_prime(m, k) do ++m end
r[i] = m
++m
m += 1
end
return r
end

View file

@ -1,6 +1,7 @@
include Settings
-- 23 Aug 2025
include Setting
say 'ALMOST PRIME - 3 Mar 2025'
say 'ALMOST PRIME'
say version
say
arg n k m
@ -33,7 +34,4 @@ end
say Format(Time('e'),,3) 'seconds'
exit
include Numbers
include Sequences
include Functions
include Abend
include Math

View file

@ -1,54 +0,0 @@
For k = 1 To 5
count = 0
increment = 1
WScript.StdOut.Write "K" & k & ": "
Do Until count = 10
If PrimeFactors(increment) = k Then
WScript.StdOut.Write increment & " "
count = count + 1
End If
increment = increment + 1
Loop
WScript.StdOut.WriteLine
Next
Function PrimeFactors(n)
PrimeFactors = 0
arrP = Split(ListPrimes(n)," ")
divnum = n
Do Until divnum = 1
For i = 0 To UBound(arrP)-1
If divnum = 1 Then
Exit For
ElseIf divnum Mod arrP(i) = 0 Then
divnum = divnum/arrP(i)
PrimeFactors = PrimeFactors + 1
End If
Next
Loop
End Function
Function IsPrime(n)
If n = 2 Then
IsPrime = True
ElseIf n <= 1 Or n Mod 2 = 0 Then
IsPrime = False
Else
IsPrime = True
For i = 3 To Int(Sqr(n)) Step 2
If n Mod i = 0 Then
IsPrime = False
Exit For
End If
Next
End If
End Function
Function ListPrimes(n)
ListPrimes = ""
For i = 1 To n
If IsPrime(i) Then
ListPrimes = ListPrimes & i & " "
End If
Next
End Function