Beautiful permutations

Write codeMedium22 min

Your task

A permutation perm of 1..n is 'beautiful' if for every 1-indexed position i, either perm[i] is divisible by i or i is divisible by perm[i]. Return the number of beautiful permutations of 1..n. 1 <= n <= 12.

Examples

beautiful_arrangement(n: int) -> int
Example 1
Inputbeautiful_arrangement(2)
Output2