Yellowstone sequence: Difference between revisions

Content added Content deleted
Line 1,010: Line 1,010:
=={{header|Racket}}==
=={{header|Racket}}==


<lang racket></lang>
<lang racket>#lang racket

(require plot)

(define a098550
(let ((hsh# (make-hash '((1 . 1) (2 . 2) (3 . 3))))
(rev# (make-hash '((1 . 1) (2 . 2) (3 . 3)))))
(λ (n)
(hash-ref hsh# n
(λ ()
(let ((a_n (for/first ((i (in-naturals 4))
#:unless (hash-has-key? rev# i)
#:when (and (= (gcd i (a098550 (- n 1))) 1)
(> (gcd i (a098550 (- n 2))) 1)))
i)))
(hash-set! hsh# n a_n)
(hash-set! rev# a_n n)
a_n))))))

(map a098550 (range 1 (add1 30)))

(plot (points
(map (λ (i) (vector i (a098550 i))) (range 1 (add1 100)))))</lang>


{{out}}
{{out}}
Line 1,016: Line 1,038:
Just the output text... you'll have to run this yourself in racket to see the plot!
Just the output text... you'll have to run this yourself in racket to see the plot!


<pre>'(1 2 3 4 9 8 15 14 5 6 25 12 35 16 7 10 21 20 27 22 39 11 13 33 26 45 28 51 32 17)</pre>
<pre></pre>


=={{header|Raku}}==
=={{header|Raku}}==