Files
freeCodeCamp/curriculum/challenges/italian/10-coding-interview-prep/project-euler/problem-323-bitwise-or-operations-on-random-integers.md
2022-03-01 21:39:26 +05:30

1.1 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
5900f4b01000cf542c50ffc2 Problema 323: Operazioni sui bit di interi casuali 5 301980 problem-323-bitwise-or-operations-on-random-integers

--description--

Sia y_0, y_1, y_2, \ldots una sequenza di numeri interi casuali a 32 bit senza segno

(cioè 0 ≤ y_i < 2^{32}, con ogni valore ugualmente probabile).

Per la sequenza x_i viene fornita la seguente ricorsione:

  • x_0 = 0 e
  • x_i = x_{i - 1} \mathbf{|} y_{i - 1}, per i > 0. (\mathbf{|} è l'operatore bitwise-OR)

Si può vedere che alla fine ci sarà un indice N tale che x_i = 2^{32} - 1 (un bit-pattern di solo uno) per tutti i ≥ N.

Trova il valore atteso di N. Dare la risposta arrotondata a 10 cifre dopo il punto decimale.

--hints--

bitwiseOrOnRandomIntegers() dovrebbe restituire 6.3551758451.

assert.strictEqual(bitwiseOrOnRandomIntegers(), 6.3551758451);

--seed--

--seed-contents--

function bitwiseOrOnRandomIntegers() {

  return true;
}

bitwiseOrOnRandomIntegers();

--solutions--

// solution required