Skip to content

Practice Beautiful Arrangement

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#526
LeetCode Problem

Beautiful Arrangement

Problem Statement

Count the permutations of the integers 1 through n that satisfy this condition at every 1-based position i: either the value at position i is divisible by i, or i is divisible by that value. Each integer must appear exactly once.

Source: Beautiful Arrangement on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
n = 2
Output
2

# Example 2

Input
n = 1
Output
1

Constraints

1 <= n <= 15

Related LeetCode Problems

Practice more problems similar to Beautiful Arrangement.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.