Recaman's sequence
From Fōrmulæ wiki
Revision as of 12:06, 13 December 2019 by Admin (Talk | contribs) (→Description (from Rosetta Code))
This page is a solution to the task Recaman's sequence in the Rosetta Code, written in Fōrmulæ.
Contents
Description (from Rosetta Code)
The Recamán's sequence generates Natural numbers. Starting from zero, the n'th term If the conditions don't hold then Task
References:
|
Answer
Generation of the sequence
The following snippet generates the Recaman's sequence of a given number of terms:
This is an example:
Calculating all the cases of the task in a single program
The following is the program:
Running for computation of the first 15 members of the sequence, the first duplicate and the number of terms to generate the first 1,000 integers:
Additional examples
Plotting the sequence
The following snippet creates a plot for a given sequence:
Drawing the sequence as it was shown in the Numberphile video
The program:
And an example: