A carousel has n slots numbered 1 to n, and n cards numbered 1 to n. Each slot gets exactly one card. A card fits a slot when the card number divides the slot number, or the slot number divides the card number.
Write countCompatibleOrders(n) that returns how many ways there are to place all cards so that every card fits its slot.
Input: n = 2 Output: 2
Both [1, 2] and [2, 1] work, because 1 divides everything and 2 divides 2.
Input: n = 1 Output: 1
Card 1 in slot 1.
1 <= n <= 12Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #301 Compatible Slot Orders. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.