Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
|
|
@ -0,0 +1,35 @@
|
|||
local int = require "int"
|
||||
local fmt = require "fmt"
|
||||
require "table2"
|
||||
|
||||
local function successive_primes(primes, diffs)
|
||||
local results = {}
|
||||
local dl = #diffs
|
||||
for i = 1, #primes - dl do
|
||||
local group = table.rep(dl + 1, 0)
|
||||
group[1] = primes[i]
|
||||
for j = i, i + dl - 1 do
|
||||
if primes[j + 1] - primes[j] != diffs[j - i + 1] then
|
||||
continue 2
|
||||
end
|
||||
group[j - i + 2] = primes[j + 1]
|
||||
end
|
||||
results:insert(group)
|
||||
end
|
||||
return results
|
||||
end
|
||||
|
||||
local primes = int.primes(999_999)
|
||||
local diffs_list = { {2}, {1}, {2, 2}, {2, 4}, {4, 2}, {6, 4, 2} }
|
||||
print("For primes less than 1,000,000:-\n")
|
||||
for diffs_list as diffs do
|
||||
print($" For differences of {fmt.swrite(diffs)} ->")
|
||||
local sp = successive_primes(primes, diffs)
|
||||
if #sp == 0 then
|
||||
print(" No groups found\n")
|
||||
continue
|
||||
end
|
||||
print($" First group = {fmt.swrite(sp[1])}")
|
||||
print($" Last group = {fmt.swrite(sp[#sp])}")
|
||||
print($" Number found = {#sp}\n")
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue