Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,26 @@
gsum(i) = sum(digits(i)) + i
isnonself(i) = any(x -> gsum(x) == i, i-1:-1:i-max(1, ndigits(i)*9))
const last81 = filter(isnonself, 1:5000)[1:81]
function checkselfnumbers()
i, selfcount = 1, 0
while selfcount <= 100_000_000 && i <= 1022727208
if !(i in last81)
selfcount += 1
if selfcount < 51
print(i, " ")
elseif selfcount == 51
println()
elseif selfcount == 100_000_000
println(i == 1022727208 ?
"Yes, $i is the 100,000,000th self number." :
"No, instead $i is the 100,000,000th self number.")
end
end
popfirst!(last81)
push!(last81, gsum(i))
i += 1
end
end
checkselfnumbers()

View file

@ -0,0 +1,43 @@
const MAXCOUNT = 103 * 10000 * 10000 + 11 * 9 + 1
function dosieve!(sieve, digitsum9999)
n = 1
for a in 1:103, b in 1:10000
s = digitsum9999[a] + digitsum9999[b] + n
for c in 1:10000
sieve[digitsum9999[c] + s] = true
s += 1
end
n += 10000
end
end
initdigitsum() = reverse!(vec([sum(k) for k in Iterators.product(9:-1:0, 9:-1:0, 9:-1:0, 9:-1:0)]))
function findselves()
sieve = zeros(Bool, MAXCOUNT+1)
println("Sieve time:")
@time begin
digitsum = initdigitsum()
dosieve!(sieve, digitsum)
end
cnt = 1
for i in 1:MAXCOUNT+1
if !sieve[i]
cnt > 50 && break
print(i, " ")
cnt += 1
end
end
println()
limit, cnt = 1, 0
for i in 0:MAXCOUNT
cnt += 1 - sieve[i + 1]
if cnt == limit
println(lpad(cnt, 10), lpad(i, 12))
limit *= 10
end
end
end
@time findselves()