Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
32
Task/Yellowstone-sequence/Pluto/yellowstone-sequence.pluto
Normal file
32
Task/Yellowstone-sequence/Pluto/yellowstone-sequence.pluto
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
require "table2"
|
||||
local int = require "int"
|
||||
local fmt = require "fmt"
|
||||
|
||||
local function yellowstone(n)
|
||||
local m = {}
|
||||
local a = table.rep(n, 0)
|
||||
for i = 1, 3 do
|
||||
a[i] = i
|
||||
m[i] = true
|
||||
end
|
||||
local min = 4
|
||||
for c = 4, n do
|
||||
local i = min
|
||||
while true do
|
||||
if !m[i] and int.gcd(a[c - 1], i) == 1 and int.gcd(a[c - 2], i) > 1 then
|
||||
a[c] = i
|
||||
m[i] = true
|
||||
if i == min then ++min end
|
||||
break
|
||||
end
|
||||
++i
|
||||
end
|
||||
end
|
||||
return a
|
||||
end
|
||||
|
||||
local x = {}
|
||||
for i = 1, 30 do x[i] = i end
|
||||
local y = yellowstone(30)
|
||||
print("The first 30 Yellowstone numbers are:")
|
||||
fmt.tprint("%2d ", y, 10)
|
||||
Loading…
Add table
Add a link
Reference in a new issue