Module 5 · Functions: Declarations, Arrows, Defaults and Rest
CP and Interview Pack: Recursion Patterns, Currying and the Bug Gallery
ProReading
Alice's take-home test has one line that worries her: "Compute 2 to the power 1,000,000, modulo 1,000,007, without a loop of a million." Bob says it cannot be done. Amara says it takes 21 calls. By the end of the second pattern you will see why Amara is right. You will also see why Bob's first idea, a recursion that multiplies by 2 a million times, cannot even run on Node.
Checking what this lesson needs for you…
What is inside CP and Interview Pack: Recursion Patterns, Currying and the Bug Gallery
- Pattern 1: the smaller input
- Pattern 2: halving, with fast power
- Pattern 3: include or exclude
- Pattern 4: memoisation, previewed
- The interview questions, with model answers
- Currying: add(1)(2)(3)
- Debounce, previewed with setTimeout
- What does this print?
- The contest angle