Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
31
Task/Yellowstone-sequence/Julia/yellowstone-sequence.julia
Normal file
31
Task/Yellowstone-sequence/Julia/yellowstone-sequence.julia
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using Plots
|
||||
|
||||
function yellowstone(N)
|
||||
a = [1, 2, 3]
|
||||
b = Dict(1 => 1, 2 => 1, 3 => 1)
|
||||
start = 4
|
||||
while length(a) < N
|
||||
inseries = true
|
||||
for i in start:typemax(Int)
|
||||
if haskey(b, i)
|
||||
if inseries
|
||||
start += 1
|
||||
end
|
||||
else
|
||||
inseries = false
|
||||
end
|
||||
if !haskey(b, i) && (gcd(i, a[end]) == 1) && (gcd(i, a[end - 1]) > 1)
|
||||
push!(a, i)
|
||||
b[i] = 1
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
return a
|
||||
end
|
||||
|
||||
println("The first 30 entries of the Yellowstone permutation:\n", yellowstone(30))
|
||||
|
||||
x = 1:100
|
||||
y = yellowstone(100)
|
||||
plot(x, y)
|
||||
Loading…
Add table
Add a link
Reference in a new issue