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/Maths/BinaryExponentiationRecursive.js at master · TheAlgorithms/JavaScript Expand file tree/ Copy pathBinaryExponentiationRecursive.jsMore file actions 20 lines (18 loc) · 469 Bytes / Copy pathBinaryExponentiationRecursive.jsFile metadata and controls20 lines (18 loc) · 469 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 /* Modified from: https://github.com/TheAlgorithms/Python/blob/master/maths/binary_exponentiation.py Explanation: https://en.wikipedia.org/wiki/Exponentiation_by_squaring */ export const binaryExponentiation = (a, n) => { // input: a: int, n: int // returns: a^n: int if (n === 0) { return 1 } else if (n % 2 === 1) { return binaryExponentiation(a, n - 1) * a } else { const b = binaryExponentiation(a, n / 2) return b * b } } |
| 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. |