Cody

Problem 44338. Recaman Sequence - I

Created by Mehmet OZC in Community

Recaman Sequence (A005132 - - OEIS Link) is defined as follow;

seq(0) = 0; 
for n > 0, seq(n) = seq(n-1) - n if positive and not already in the sequence, 
otherwise seq(n) = seq(n-1) + n. 
seq = 0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 11, 22, 10, 23, 9 ...
index = 1, 2, 3 ,...

To avoid zero index, start indexing from 1. return the first n elements in Recaman Sequence

Related Challenges :

  1. Recaman Sequence - I
  2. Recaman Sequence - II
  3. Recaman Sequence - III

Solution Stats

49.91% Correct | 50.09% Incorrect
Last solution submitted on Feb 11, 2019

Problem Comments

Solution Comments

Recent Solvers206

Suggested Problems

More from this Author53

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!