Skip to content

Commit 75d7649

Browse files
authored
Changes made in GrayCodes.js
1 parent f21e1c4 commit 75d7649

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Bit-Manipulation/GrayCodes.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
// To generate Gray codes using bit manipulation in JavaScript, we can create a function that takes an integer n as input and returns an array of Gray codes up to 2^n - 1
1+
/**
2+
* Generates a Gray code sequence for the given number of bits.
3+
* @param {number} n - The number of bits in the Gray code sequence.
4+
* @returns {string[]} - An array of Gray codes in binary format.
5+
*/
26
function generateGrayCodes(n) {
37
if (n <= 0) {
48
return [0]
@@ -16,4 +20,4 @@ function generateGrayCodes(n) {
1620
return grayCodes
1721
}
1822

19-
export { generateGrayCodes } // Export the function for testing
23+
export { generateGrayCodes }

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy