This pull request adds the gray_code(n) function and corresponding unit tests to generate and verify n-bit Gray code sequences. Gray code is a numeral system used in digital systems where two successive values differ by only one bit.
Key Features:
Gray Code Generator:
The function recursively generates Gray codes for any n-bit length by building on previous sequences and mirroring them.
Returns Gray code in decimal representation.
Comprehensive Unit Tests:
A set of unit tests is included to validate the correctness of the Gray code generator for various bit lengths.
Tests for 0-bit, 1-bit, 2-bit, 3-bit, and 4-bit Gray code sequences, ensuring accuracy of the output.
Description:
This pull request adds the
gray_code(n)
function and corresponding unit tests to generate and verify n-bit Gray code sequences. Gray code is a numeral system used in digital systems where two successive values differ by only one bit.Key Features:
Gray Code Generator:
Comprehensive Unit Tests: