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,34 @@
local int = require "int"
local fmt = require "fmt"
require "table2"
local arithmetic = {1}
local primes = {}
local limit = 1e6
local n = 3
while #arithmetic < limit do
local divs = int.divisors(n)
if #divs == 2 then
primes:insert(n)
arithmetic:insert(n)
else
local mean = divs:mean()
if mean % 1 == 0 then arithmetic:insert(n) end
end
n += 1
end
print("The first 100 arithmetic numbers are:")
fmt.tprint("%3d", arithmetic:slice(1, 100), 10)
for {1e3, 1e4, 1e5, 1e6} as x do
local last = arithmetic[x]
fmt.print("\nThe %,sth arithmetic number is: %,s", x, last)
local pcount = primes:findindex(|p| -> p >= last, 1, true)
if !pcount then
pcount = #primes
elseif !int.isprime(last) then
pcount -= 1;
end
local comp = x - pcount - 1 -- 1 is not composite
fmt.print("The count of such numbers <= %,s which are composite is %,s.", last, comp)
end