2021-06-15 00:49:18 -07:00
---
id: 5900f4b01000cf542c50ffc2
2022-03-01 21:39:26 +05:30
title: 'Problema 323: Operazioni sui bit di interi casuali'
2021-06-15 00:49:18 -07:00
challengeType: 5
forumTopicId: 301980
dashedName: problem-323-bitwise-or-operations-on-random-integers
---
# --description--
2022-03-31 22:31:59 +05:30
Sia $y_0, y_1, y_2, \ldots$ una successione casuale di numeri interi senza segno a 32 bit (cioè $0 ≤ y_i < 2^{32}$, ogni valore altrettanto probabile).
2021-06-15 00:49:18 -07:00
2022-03-31 22:31:59 +05:30
Per la successione $x_i$ viene data la seguente ricorsione:
2021-06-15 00:49:18 -07:00
2022-03-01 21:39:26 +05:30
- $x_0 = 0$ e
- $x_i = x_{i - 1} \mathbf{|} y_{i - 1}$, per $i > 0$. ($\mathbf{|}$ è l'operatore bitwise-OR)
2021-06-15 00:49:18 -07:00
2022-03-31 22:31:59 +05:30
Si può vedere che alla fine ci sarà un indice $N$ tale che $x_i = 2^{32} - 1$ (un pattern con tutti i bit a uno) per tutti gli i $i ≥ N$.
2021-06-15 00:49:18 -07:00
2022-03-31 22:31:59 +05:30
Trova il valore atteso di $N$. Dai la tua risposta arrotondata a 10 cifre dopo il punto decimale.
2021-06-15 00:49:18 -07:00
# --hints--
2022-03-01 21:39:26 +05:30
`bitwiseOrOnRandomIntegers()` dovrebbe restituire `6.3551758451` .
2021-06-15 00:49:18 -07:00
```js
2022-03-01 21:39:26 +05:30
assert.strictEqual(bitwiseOrOnRandomIntegers(), 6.3551758451);
2021-06-15 00:49:18 -07:00
```
# --seed--
## --seed-contents--
```js
2022-03-01 21:39:26 +05:30
function bitwiseOrOnRandomIntegers() {
2021-06-15 00:49:18 -07:00
return true;
}
2022-03-01 21:39:26 +05:30
bitwiseOrOnRandomIntegers();
2021-06-15 00:49:18 -07:00
```
# --solutions--
```js
// solution required
```