RosettaCodeData/Task/Recamans-sequence/Uiua/recamans-sequence.uiua
2026-04-30 12:34:36 -04:00

9 lines
556 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.

# Sofar A(n-1) n Seen
Start ← [0] 0 1 1_0_0_0
N ← ⨬(˜-|+)⤚₂(⬚1⊡˜-) # A(n-1) - n if valid, else A(n-1) + n.
Seen ← ⍜⊡⋅1⟜(⬚0↙↥⊸⊓+₁⧻)⊙⋅⋅∘ # Update Seen, expanding as needed.
Step ← ⊃(⊃(∘|⋅⋅+₁)|Seen)◡N # Run one step.
&p$"First fifteen terms: \n_"⍥⤚Step15 ◌ Start
&p$"First repeat: _"⋅⊙⋅◌⍢(⊸⊂⊙Step|=∩⧻⊸◴) Start
&p$"...Thinking for _ seconds..."⍜now(⍢(⊸⊂⊙Step|≠1000/+⬚0↙1000⋅⋅⋅∘) Start)
&p$"0-1000 generated at: _"⋅⋅⊙◌