RosettaCodeData/Task/Yellowstone-sequence/11l/yellowstone-sequence-1.11l
2023-07-01 13:44:08 -04:00

30 lines
609 B
Text
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

T YellowstoneGenerator
min_ = 1
n_ = 0
n1_ = 0
n2_ = 0
Set[Int] sequence_
F next()
.n2_ = .n1_
.n1_ = .n_
I .n_ < 3
.n_++
E
.n_ = .min_
L !(.n_ !C .sequence_ & gcd(.n1_, .n_) == 1 & gcd(.n2_, .n_) > 1)
.n_++
.sequence_.add(.n_)
L
I .min_ !C .sequence_
L.break
.sequence_.remove(.min_)
.min_++
R .n_
print(First 30 Yellowstone numbers:)
V ygen = YellowstoneGenerator()
print(ygen.next(), end' )
L(i) 1 .< 30
print( ygen.next(), end' )
print()