GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — JavaScript/Recursive/BinaryEquivalent.js at master · TheAlgorithms/JavaScript Expand file tree/ Copy pathBinaryEquivalent.jsMore file actions 21 lines (20 loc) · 578 Bytes / Copy pathBinaryEquivalent.jsFile metadata and controls21 lines (20 loc) · 578 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 /* * Problem Statement: Given a positive number `num`, find it's binary equivalent using recursion * * What is Binary Equivalent? * - In binary number system, a number is represented in terms of 0s and 1s, * for example: * - Binary Of 2 = 10 * - Binary of 3 = 11 * - Binary of 4 = 100 * * Reference on how to find Binary Equivalent * - https://byjus.com/maths/decimal-to-binary/ * */ export const binaryEquivalent = (num) => { if (num === 0 || num === 1) { return String(num) } return binaryEquivalent(Math.floor(num / 2)) + String(num % 2) } |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |