Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Beautiful Arrangement

A permutation of 1..n is beautiful if for every position i (1-based) either perm[i] is divisible by i or i is divisible by perm[i]. Print the number of beautiful arrangements.

Constraints

1 <= n <= 15

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.