Data update

This commit is contained in:
Ingy döt Net 2024-10-16 18:07:41 -07:00
parent 81fd053722
commit 52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions

View file

@ -1,44 +1,44 @@
fun chowla = int by int n
int sum = 0
int j = 0
for int i = 2; i * i <= n; i++ do
if n % i == 0 do sum += i + when(i == (j = n / i), 0, j) end
fun chowla int by int n
int sum 0
int j 0
for int i ← 2; i * i ≤ n; ++i do
if n % i æ 0 do sum += i + when(i æ (j ← n / i), 0, j) end
end
return sum
end
fun sieve = List by int limit
List c = logic[].with(limit)
for int i = 3; i * 3 < limit; i += 2
if c[i] or chowla(i) != 0 do continue end
for int j = 3 * i; j < limit; j += 2 * i do c[j] = true end
fun sieve List by int limit
List c logic[].with(limit)
for int i 3; i * 3 < limit; i += 2
if c[i] or chowla(i) 0 do continue end
for int j ← 3 * i; j < limit; j += 2 * i do c[j] ← true end
end
return c
end
# find and display (1 per line) for the 1st 37 integers
for int i = 1; i <= 37; i++ do writeLine("chowla(" + i + ") = " + chowla(i)) end
int count = 1
int limit = 10000000
int power = 100
List c = sieve(limit)
for int i = 3; i < limit; i += 2
if not c[i] do count++ end
if i == power - 1
writeLine("Count of primes up to " + power + " = " + count)
for int i ← 1; i ≤ 37; ++i do writeLine("chowla(" + i + ") = ", chowla(i)) end
int count 1
int limit 10000000
int power 100
List c sieve(limit)
for int i 3; i < limit; i += 2
if not c[i] do ++count end
if i æ power - 1
writeLine("Count of primes up to ", power, " = ", count)
power *= 10
end
end
count = 0
limit = 35000000
int k = 2
int kk = 3
count 0
limit 35000000
int k 2
int kk 3
int p
for int i = 2; ; i++
if (p = k * kk) > limit do break end
if chowla(p) == p - 1
writeLine(p + " is a number that is perfect")
count++
for int i ← 2; ; ++i
if (p k * kk) > limit do break end
if chowla(p) æ p - 1
writeLine(p, " is a number that is perfect")
++count
end
k = kk + 1
k kk + 1
kk += k
end
writeLine("There are " + count + " perfect numbers <= 35,000,000")
writeLine("There are ", count, " perfect numbers ≤ 35,000,000")

View file

@ -0,0 +1,54 @@
function chowla(n: Integer): Integer;
begin
result := 0;
var i := 2;
while i * i <= n do
begin
if n mod i = 0 then
result += i + (if i = n div i then 0 else n div i);
i += 1
end;
end;
function sieve(limit: Integer): array of Boolean;
begin
result := new Boolean[limit];
for var i := 3 to limit div 3 step 2 do
if not result[i] and (chowla(i) = 0) Then
for var j := 3 * i to limit step 2 * i do
result[j] := true;
end;
begin
for var i := 1 To 37 do
WriteLn('chowla(', i, ') = ', chowla(i));
var count := 1;
var limit := 10_000_000;
var power := 100;
var c := sieve(limit);
for var i := 3 To limit Step 2 do
begin
if not c[i] Then count += 1;
if i = power - 1 Then begin
WriteLn('Count of primes up to ', power:8, ' = ', count);
power *= 10;
end;
end;
count := 0;
limit := 35_000_000;
var k := 2; var kk := 3;
while True do
begin
var p := k * kk;
if p > limit Then break;
if chowla(p) = p - 1 Then begin
WriteLn(p:8, ' is a number that is perfect');
count += 1;
end;
k := kk + 1;
kk += k;
end;
WriteLn('There are ', count, ' perfect numbers <= 35,000,000')
end.

View file

@ -0,0 +1,81 @@
include Settings
say version; say 'Chowla numbers'; say
numeric digits 12
call ChowlaNumbers
call PrimeCount
call PerfectNumbers
exit
ChowlaNumbers:
procedure expose glob.
call Time('r'); sep = Copies('-',12)
say sep; say ' n Chowla(n)'; say sep
m = 37
do i = 1 to m
say Right(i,2) Right(Chowla(i),9)
end
say sep
say Format(Time('e'),,3) 'seconds'
say
return
PrimeCount:
procedure expose glob. work.
call Time('r'); sep = Copies('-',17)
say sep; say Right('n',8) Right('Primes<n',8); say sep
d = 1; work. = 1; m = 1e7; n = 0
do i = 1 by 2 to m+1
e = Xpon(i)
if e > d then do
say Right(10**e,8) Right(n,8)
d = e
end
if work.i = 0 then
iterate i
if Chowla(i) = 0 then do
n = n+1
if i > 1 then do
j = i+i
do while j < m
work.j = 0; j = j+i
end
end
end
end
say sep
say Format(Time('e'),,3) 'seconds'
say
return
PerfectNumbers:
procedure expose divi.
call Time('r'); sep = Copies('-',12)
say sep; say Right('Perfect',12); say sep
k = 2; kk = 3; m = 140e9; n = 0
do forever
p = k * kk
if p > 140e9 then
leave
if Chowla(p) = p-1 then do
n = n+1
say Right(p,12)
end
k = kk+1; kk = kk+k
end
say sep
say n 'perfect numbers found below 140e9'
say Format(Time('e'),,3) 'seconds'
say
return
Chowla:
/* Chowla numbers */
procedure expose divi.
arg x
/* Formula */
return Aliquot(x)-1
include Numbers
include Functions
include Abend