Calculate storage capacity of RAID 2 / 3 / 4?

Given `n` drives and capacity `s` of each drive, how would I calculate storage capacity for RAID 2 / 3 / 4?

For example, I know RAID 5's storage capacity can be calculated with the following formula:

``````(n - 1) * s
``````
-

RAID 2

A RAID 2 stripes data at the bit (rather than block) level, and uses a Hamming code for error correction. This code uses m parity bits out of 2m - 1 bits therefor the storage capacity for n disks would be 2m - m - 1 where m = log2(n+1). Here are some possible scenarios:

``````+--------------+-------------+------------------+
| Parity disks | Total disks | Storage capacity |
+--------------+-------------+------------------+
| 2            | 3           | 1 * s            |
+--------------+-------------+------------------+
| 3            | 7           | 4 * s            |
+--------------+-------------+------------------+
| 4            | 15          | 11 * s           |
+--------------+-------------+------------------+
| 5            | 31          | 26 * s           |
+--------------+-------------+------------------+
``````

RAID 3

A RAID 3 uses byte-level striping with a dedicated parity disk, so the capacity is (n - 1) * s.

RAID 4

A RAID 4 uses block-level striping with a dedicated parity disk, so again the capacity is (n - 1) * s.

-