Data update

This commit is contained in:
Ingy döt Net 2026-04-30 12:34:36 -04:00
parent 4bb20c9b71
commit cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions

View file

@ -0,0 +1,37 @@
begin
comment - return n mod m;
integer procedure mod(n, m);
value n, m; integer n, m;
begin
mod := n - entier(n/m) * m;
end;
comment - return number of divisors of n;
integer procedure tau(n);
value n; integer n;
begin
integer i, t, limit;
if n < 3 then
t := n
else
begin
t := 2;
limit := (n + 1) / 2;
for i := 2 step 1 until limit do
begin
if mod(n, i) = 0 then t := t + 1;
end;
end;
tau := t;
end;
integer i;
outstring(1,"Number of divisors of first 100 numbers\n");
for i := 1 step 1 until 100 do
begin
outinteger(1,tau(i));
if mod(i,10) = 0 then outstring(1,"\n");
end;
end

View file

@ -0,0 +1,23 @@
scope # find the count of the divisors of the first 100 positive integers
# returns the number of divisors of v
local proc divisor_count( v :: number ) :: number
# numtheory.ifactors will return something like (e.g., for 24): [1, [[2, 3], [3, 1]]]
local total := 1;
if v > 1 then
local constant factors := numtheory.ifactors( v );
for f to size factors[ 2 ] do
total *:= factors[ 2, f, 2 ] + 1
od
fi;
return total
end;
scope
local constant limit := 100;
printf( "Count of divisors for the first %d positive integers:\n", limit );
for n to limit do
printf( "%3d", divisor_count( n ) );
if n mod 20 = 0 then print() else printf( " " ) fi
od
end
end

View file

@ -0,0 +1,65 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. TAU-FUNCTION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 TAU-VARS.
03 TOTAL PIC 999.
03 N PIC 999.
03 FILLER REDEFINES N.
05 FILLER PIC 99.
05 FILLER PIC 9.
88 N-EVEN VALUES 0, 2, 4, 6, 8.
03 P PIC 999.
03 P-SQUARED PIC 999.
03 N-DIV-P PIC 999V999.
03 FILLER REDEFINES N-DIV-P.
05 NEXT-N PIC 999.
05 FILLER PIC 999.
88 DIVISIBLE VALUE ZERO.
03 F-COUNT PIC 999.
01 CONTROL-VARS.
03 I PIC 999.
01 OUT-VARS.
03 OUT-ITM PIC ZZ9.
03 OUT-STR PIC X(80) VALUE SPACES.
03 OUT-PTR PIC 99 VALUE 1.
PROCEDURE DIVISION.
BEGIN.
PERFORM SHOW-TAU VARYING I FROM 1 BY 1
UNTIL I IS GREATER THAN 100.
STOP RUN.
SHOW-TAU.
MOVE I TO N.
PERFORM TAU.
MOVE TOTAL TO OUT-ITM.
STRING OUT-ITM DELIMITED BY SIZE INTO OUT-STR
WITH POINTER OUT-PTR.
IF OUT-PTR IS EQUAL TO 61,
DISPLAY OUT-STR,
MOVE 1 TO OUT-PTR.
TAU.
MOVE 1 TO TOTAL.
PERFORM POWER-OF-2 UNTIL NOT N-EVEN.
MOVE ZERO TO P-SQUARED.
PERFORM ODD-FACTOR THRU ODD-FACTOR-LOOP
VARYING P FROM 3 BY 2
UNTIL P-SQUARED IS GREATER THAN N.
IF N IS GREATER THAN 1,
MULTIPLY 2 BY TOTAL.
POWER-OF-2.
ADD 1 TO TOTAL.
DIVIDE 2 INTO N.
ODD-FACTOR.
MULTIPLY P BY P GIVING P-SQUARED.
MOVE 1 TO F-COUNT.
ODD-FACTOR-LOOP.
DIVIDE N BY P GIVING N-DIV-P.
IF DIVISIBLE,
MOVE NEXT-N TO N,
ADD 1 TO F-COUNT,
GO TO ODD-FACTOR-LOOP.
MULTIPLY F-COUNT BY TOTAL.

View file

@ -1,18 +1,18 @@
fun divisorCount = int by int n
int total = 1
for ; (n & 1) == 0; n /= 2 do ++total end
for int p = 3; p * p <= n; p += 2
int count = 1
for ; n % p == 0; n /= p do ++count end
total *= count
fun divisorCount int by int n
int total 1
for ; (n & 1) æ 0; n /← 2 do ++total end
for int p ← 3; p * p ≤ n; p +← 2
int count 1
for ; n % p æ 0; n /← p do ++count end
total * count
end
if n > 1 do total *= 2 end
if n > 1 do total * 2 end
return total
end
int limit = 100
int limit 100
writeLine("Count of divisors for the first " + limit + " positive integers:")
for int n = 1; n <= limit; ++n
text value = text!divisorCount(n)
for int n ← 1; n ≤ limit; ++n
text value text!divisorCount(n)
write((" " * (3 - value.length)) + value)
if n % 20 == 0 do writeLine() end
if n % 20 æ 0 do writeLine() end
end

View file

@ -1,16 +1,17 @@
func cntdiv n .
i = 1
while i <= sqrt n
if n mod i = 0
func divcnt n .
tot = 1
p = 2
while p <= sqrt n
cnt = 1
while n mod p = 0
cnt += 1
if i <> n div i
cnt += 1
.
n /= p
.
i += 1
tot *= cnt
p += 1
.
return cnt
.
for i to 100
write cntdiv i & " "
if n > 1 : tot *= 2
return tot
.
for i to 100 : write divcnt i & " "
print ""

View file

@ -0,0 +1,45 @@
(do ;;; find the count of the divisors of the first 100 positive integers
; returns the number of divisors of v
(fn divisor-count [v]
(var (total n) (values 1 v))
; Deal with powers of 2 first
(while (= 0 (% n 2))
(set total (+ total 1))
(set n (math.floor (/ n 2)))
)
; Odd prime factors up to the square root
(var p 1)
(while (do (set p (+ p 2))
(<= (* p p) n)
)
(var count 1)
(while (= 0 (% n p))
(set count (+ count 1))
(set n (math.floor (/ n p)))
)
(set total (* total count))
)
; If n > 1 then it's prime
(when (> n 1)
(set total (* total 2))
)
total
)
(do
(local limit 100)
(io.write (.. "Count of divisors for the first " limit " positive integers:\n"))
(for [n 1 limit]
(io.write (string.format "%3d%s"
(divisor-count n)
(if (= 0 (% n 20))
"\n"
;else
" "
)
)
)
)
)
)

View file

@ -0,0 +1,9 @@
procedure main()
every writes(" ",tau(seq()))\100
write()
end
procedure tau(n)
every (c := 0, n%(1 to n) = 0, c +:= 1)
return c
end

View file

@ -0,0 +1 @@
makelist(cardinality(divisors(i)), i, 1, 100);

View file

@ -1,6 +1,4 @@
(phixonline)-->
<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;">100</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: #008000;">"%3d"</span><span style="color: #0000FF;">,{</span><span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">factors</span><span style="color: #0000FF;">(</span><span style="color: #000000;">i</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">))})</span>
<span style="color: #008080;">if</span> <span style="color: #7060A8;">remainder</span><span style="color: #0000FF;">(</span><span style="color: #000000;">i</span><span style="color: #0000FF;">,</span><span style="color: #000000;">20</span><span style="color: #0000FF;">)=</span><span style="color: #000000;">0</span> <span style="color: #008080;">then</span> <span style="color: #7060A8;">puts</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"\n"</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<!--
for i=1 to 100 do
printf(1,"%3d",{length(factors(i,1))})
if remainder(i,20)=0 then puts(1,"\n") end if
end for

View file

@ -1,4 +1,2 @@
(phixonline)-->
<span style="color: #004080;">sequence</span> <span style="color: #000000;">r</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">apply</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">apply</span><span style="color: #0000FF;">(</span><span style="color: #004600;">true</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">factors</span><span style="color: #0000FF;">,{</span><span style="color: #7060A8;">tagset</span><span style="color: #0000FF;">(</span><span style="color: #000000;">100</span><span style="color: #0000FF;">),{</span><span style="color: #000000;">1</span><span style="color: #0000FF;">}}),</span><span style="color: #7060A8;">length</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">puts</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">join_by</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">apply</span><span style="color: #0000FF;">(</span><span style="color: #004600;">true</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">sprintf</span><span style="color: #0000FF;">,{{</span><span style="color: #008000;">"%3d"</span><span style="color: #0000FF;">},</span><span style="color: #000000;">r</span><span style="color: #0000FF;">}),</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">20</span><span style="color: #0000FF;">,</span><span style="color: #008000;">""</span><span style="color: #0000FF;">))</span>
<!--
sequence r = apply(apply(true,factors,{tagset(100),{1}}),length)
puts(1,join_by(apply(true,sprintf,{{"%3d"},r}),1,20,""))

View file

@ -0,0 +1,2 @@
Tau ← -⊃(=|×2/+=0◿⇡₁◌)⟜⌊⊸√
↯[5 20] ≡Tau ⇡₁100