Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,16 +1,33 @@
|
|||
BEGIN # find some Chowla numbers ( Chowla n = sum of divisors of n excluding n and 1 ) #
|
||||
BEGIN # find some Chowla numbers ( Chowla n = sum of divisors of n exclusing n and 1 ) #
|
||||
|
||||
# returns the divisor sums of [1 n], the sums exclude 1 and n #
|
||||
PROC sum divisors = ( INT n )[]INT:
|
||||
BEGIN
|
||||
[ 1 : n ]INT sums;
|
||||
FOR i TO n DO sums[ i ] := 0 OD;
|
||||
FOR i FROM 2 TO n DO
|
||||
FOR j FROM i + i BY i TO n DO sums[ j ] +:= i OD
|
||||
OD;
|
||||
sums
|
||||
END # sum divisors # ;
|
||||
|
||||
[]INT ds = sum divisors( 10 000 000 ); # get a table of divisor sums for 1..n #
|
||||
|
||||
# returs the Chowla number of n #
|
||||
PROC chowla = ( INT n )INT:
|
||||
BEGIN
|
||||
INT sum := 0;
|
||||
FOR i FROM 2 WHILE i * i <= n DO
|
||||
IF n MOD i = 0 THEN
|
||||
INT j = n OVER i;
|
||||
sum +:= i + IF i = j THEN 0 ELSE j FI
|
||||
FI
|
||||
OD;
|
||||
sum
|
||||
END # chowla # ;
|
||||
IF n < 2
|
||||
THEN 0
|
||||
ELIF n <= UPB ds - LWB ds + 1
|
||||
THEN ds[ n ]
|
||||
ELSE INT sum := 0;
|
||||
FOR i FROM 2 WHILE i * i <= n DO
|
||||
IF n MOD i = 0 THEN
|
||||
INT j = n OVER i;
|
||||
sum +:= i + IF i = j THEN 0 ELSE j FI
|
||||
FI
|
||||
OD;
|
||||
sum
|
||||
FI # chowla # ;
|
||||
|
||||
FOR n TO 37 DO print( ( "chowla(", whole( n, 0 ), ") = ", whole( chowla( n ), 0 ), newline ) ) OD;
|
||||
|
||||
|
|
@ -23,7 +40,7 @@ BEGIN # find some Chowla numbers ( Chowla n = sum of divisors of n excluding n a
|
|||
FI
|
||||
OD;
|
||||
count := 0;
|
||||
INT limit = 350 000 000;
|
||||
INT limit = 35 000 000;
|
||||
INT k := 2, kk := 3;
|
||||
WHILE INT p = k * kk;
|
||||
p <= limit
|
||||
|
|
|
|||
|
|
@ -1,70 +0,0 @@
|
|||
with Ada.Text_IO;
|
||||
|
||||
procedure Chowla_Numbers is
|
||||
|
||||
function Chowla (N : Positive) return Natural is
|
||||
Sum : Natural := 0;
|
||||
I : Positive := 2;
|
||||
J : Positive;
|
||||
begin
|
||||
while I * I <= N loop
|
||||
if N mod I = 0 then
|
||||
J := N / I;
|
||||
Sum := Sum + I + (if I = J then 0 else J);
|
||||
end if;
|
||||
I := I + 1;
|
||||
end loop;
|
||||
return Sum;
|
||||
end Chowla;
|
||||
|
||||
procedure Put_37_First is
|
||||
use Ada.Text_IO;
|
||||
begin
|
||||
for A in Positive range 1 .. 37 loop
|
||||
Put_Line ("chowla(" & A'Image & ") = " & Chowla (A)'Image);
|
||||
end loop;
|
||||
end Put_37_First;
|
||||
|
||||
procedure Put_Prime is
|
||||
use Ada.Text_IO;
|
||||
Count : Natural := 0;
|
||||
Power : Positive := 100;
|
||||
begin
|
||||
for N in Positive range 2 .. 10_000_000 loop
|
||||
if Chowla (N) = 0 then
|
||||
Count := Count + 1;
|
||||
end if;
|
||||
if N mod Power = 0 then
|
||||
Put_Line ("There are " & Count'Image & " primes < " & Power'Image);
|
||||
Power := Power * 10;
|
||||
end if;
|
||||
end loop;
|
||||
end Put_Prime;
|
||||
|
||||
procedure Put_Perfect is
|
||||
use Ada.Text_IO;
|
||||
Count : Natural := 0;
|
||||
Limit : constant := 350_000_000;
|
||||
K : Natural := 2;
|
||||
Kk : Natural := 3;
|
||||
P : Natural;
|
||||
begin
|
||||
loop
|
||||
P := K * Kk;
|
||||
exit when P > Limit;
|
||||
|
||||
if Chowla (P) = P - 1 then
|
||||
Put_Line (P'Image & " is a perfect number");
|
||||
Count := Count + 1;
|
||||
end if;
|
||||
K := Kk + 1;
|
||||
Kk := Kk + K;
|
||||
end loop;
|
||||
Put_Line ("There are " & Count'Image & " perfect numbers < " & Limit'Image);
|
||||
end Put_Perfect;
|
||||
|
||||
begin
|
||||
Put_37_First;
|
||||
Put_Prime;
|
||||
Put_Perfect;
|
||||
end Chowla_Numbers;
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
-- 28 Jul 2025
|
||||
include Settings
|
||||
-- 23 Aug 2025
|
||||
include Setting
|
||||
numeric digits 12
|
||||
|
||||
say 'CHOWLA NUMBERS'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue