Recaman's sequence: Difference between revisions

Content added Content deleted
(Add COBOL)
m (added whitespace.)
Line 1: Line 1:
{{task}}
{{task}}
The '''[[wp:Recamán's sequence|Recamán's sequence]]''' generates Natural numbers.<br>
The '''[[wp:Recamán's sequence|Recamán's sequence]]''' generates Natural numbers.

Starting from zero, the n'th term <code>a(n)</code> is the previous term minus <code>n</code> i.e <code>a(n) = a(n-1) - n</code> but only if this is '''both''' positive ''and'' has not been previousely generated.<br>
Starting from zero, the n'th term <code>a(n)</code> is the previous term minus <code>n</code> i.e <code>a(n) = a(n-1) - n</code> but only if this is '''both''' positive ''and'' has not been previousely generated.<br>


If the conditions ''don't'' hold then <code>a(n) = a(n-1) + n</code>.
If the conditions ''don't'' hold then <code>a(n) = a(n-1) + n</code>.



;Task:
;Task: