--- title: Hofstadter Figure-Figure sequences id: 59622f89e4e137560018a40e challengeType: 5 videoUrl: '' localeTitle: Sequências Figura-Figura de Hofstadter --- ## Description

Essas duas seqüências de inteiros positivos são definidas como:

$$ R (1) = 1 \; \ S (1) = 2 \\ R (n) = R (n-1) + S (n-1), \ quad n> 1.

A sequência $ S (n) $ é ainda definida como a sequência de inteiros positivos não presentes em $ R (n) $ .

Seqüência $ R $ começa:

1, 3, 7, 12, 18, ...

Seqüência $ S $ começa:

2, 4, 5, 6, 8, ...

Tarefa: Crie duas funções chamadas ffr e ffs que, quando fornecidas, retornam R (n) ou S (n), respectivamente (observe que R (1) = 1 e S (1) = 2 para evitar erros entre-um). . Nenhum valor máximo para n deve ser assumido. A005228 e A030124 de Sloane. Wolfram MathWorld Wikipedia: Sequências de figura-figura de Hofstadter .
## Instructions
## Tests
```yml tests: - text: ffr é uma função. testString: 'assert(typeof ffr === "function", "ffr is a function.");' - text: ffs é uma função. testString: 'assert(typeof ffs === "function", "ffs is a function.");' - text: ffr deve retornar inteiro. testString: 'assert(Number.isInteger(ffr(1)), "ffr should return integer.");' - text: ffs deve retornar inteiro. testString: 'assert(Number.isInteger(ffs(1)), "ffs should return integer.");' - text: ffr() deve retornar 69 testString: 'assert.equal(ffr(ffrParamRes[0][0]), ffrParamRes[0][1], "ffr() should return 69");' - text: ffr() deve retornar 1509 testString: 'assert.equal(ffr(ffrParamRes[1][0]), ffrParamRes[1][1], "ffr() should return 1509");' - text: ffr() deve retornar 5764 testString: 'assert.equal(ffr(ffrParamRes[2][0]), ffrParamRes[2][1], "ffr() should return 5764");' - text: ffr() deve retornar 526334 testString: 'assert.equal(ffr(ffrParamRes[3][0]), ffrParamRes[3][1], "ffr() should return 526334");' - text: ffs() deve retornar 14 testString: 'assert.equal(ffs(ffsParamRes[0][0]), ffsParamRes[0][1], "ffs() should return 14");' - text: ffs() deve retornar 59 testString: 'assert.equal(ffs(ffsParamRes[1][0]), ffsParamRes[1][1], "ffs() should return 59");' - text: ffs() deve retornar 112 testString: 'assert.equal(ffs(ffsParamRes[2][0]), ffsParamRes[2][1], "ffs() should return 112");' - text: ffs() deve retornar 1041 testString: 'assert.equal(ffs(ffsParamRes[3][0]), ffsParamRes[3][1], "ffs() should return 1041");' ```
## Challenge Seed
```js // noprotect function ffr(n) { return n; } function ffs(n) { return n; } ```
### After Test
```js console.info('after the test'); ```
## Solution
```js // solution required ```