Skip to main content

Practice · 1 of 5

Trace the parity machine

CHALLENGE
Difficulty: advanced+25 XP

Trace **on paper**, then return the value: ``java public static int mystery(int n) { if (n <= 0) { return 0; } if (n % 2 == 0) { return mystery(n - 1) + 2; } return mystery(n - 1) * 2; } ` Implement process(int n) to return mystery(n)` for the given input n = 5.

Back to lesson: Practice: Recursion gauntlet