Cody

# Problem 44338. Recaman Sequence - I

Solution 1543931

Submitted on 30 May 2018 by Danuanping
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
x = 1; y_correct = 0; assert(isequal(Recaman(x),y_correct))

y = 0

2   Pass
x = 5; y_correct = [0 1 3 6 2]; assert(isequal(Recaman(x),y_correct))

y = 0 1 3 6 2

3   Pass
x = 8; y_correct = [0 1 3 6 2 7 13 20]; assert(isequal(Recaman(x),y_correct))

y = 0 1 3 6 2 7 13 20

4   Pass
x = 10; y_correct = [0 1 3 6 2 7 13 20 12 21]; assert(isequal(Recaman(x),y_correct))

y = 0 1 3 6 2 7 13 20 12 21

5   Pass
x = 5e4; y = Recaman(x); assert(isequal(length(Recaman(x)),x)) assert(isequal(y(954),739)) assert(isequal(y(7589),17654)) assert(isequal(y(12345),18554))

y = Columns 1 through 14 0 1 3 6 2 7 13 20 12 21 0 0 0 0 Columns 15 through 28 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 29 through 42 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 43 through 56 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 57 through 70 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 71 through 84 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 85 through 98 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 99 through 112 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 113 through 126 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 127 through 140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 141 through 154 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 155 through 168 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 169 through 182 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 183 through 196 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 197 through 210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 211 through 224 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 225 through 238 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 239 through 252 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 253 through 266 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 267 through 280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 281 through 294 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 295 through 308 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 309 through 322 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 323 through 336 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 337 through 350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 351 through 364 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 365 through 378 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 379 through 392 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 393 through 406 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 407 through 420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 421 through 434 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 435 through 448 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 449 through 462 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 463 through 476 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 477 through 490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 491 through 504 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 505 through 518 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 519 through 532 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 533 through 546 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 547 through 560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 561 through 574 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 575 through 588 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 589 through 602 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 603 through 616 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 617 through 630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 631 through 644 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 645 through 658 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 659 through 672 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 673 through 686 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 687 through 700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 701 through 714 0 0 0 0 0 0 0 0 0 0 0 ...

6   Pass
x = 1e5; y = Recaman(x); assert(isequal(length(Recaman(x)),x)) assert(isequal(y(1e4),8658)) assert(isequal(y(2e4),34358)) assert(isequal(y(3e4),92474)) assert(isequal(y(4e4),102344))

y = Columns 1 through 14 0 1 3 6 2 7 13 20 12 21 0 0 0 0 Columns 15 through 28 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 29 through 42 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 43 through 56 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 57 through 70 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 71 through 84 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 85 through 98 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 99 through 112 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 113 through 126 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 127 through 140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 141 through 154 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 155 through 168 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 169 through 182 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 183 through 196 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 197 through 210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 211 through 224 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 225 through 238 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 239 through 252 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 253 through 266 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 267 through 280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 281 through 294 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 295 through 308 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 309 through 322 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 323 through 336 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 337 through 350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 351 through 364 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 365 through 378 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 379 through 392 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 393 through 406 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 407 through 420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 421 through 434 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 435 through 448 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 449 through 462 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 463 through 476 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 477 through 490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 491 through 504 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 505 through 518 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 519 through 532 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 533 through 546 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 547 through 560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 561 through 574 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 575 through 588 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 589 through 602 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 603 through 616 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 617 through 630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 631 through 644 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 645 through 658 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 659 through 672 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 673 through 686 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 687 through 700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 701 through 714 0 0 0 0 0 0 0 0 0 0 0 ...