👩💻 Join our community of thousands of amazing developers!

2992. Number of Self-Divisible Permutations Given an integer n, return the number of permutations of the 1-indexed array nums = [1, 2, ..., n], such that it’s self-divisible. A 1-indexed array a of length n is self-divisible if for every 1 <= i <= n, gcd(a[i], i) == 1. A permutation of an array is a rearrangement of the elements of that array, for example here are all of the permutations of the array [1, 2, 3]: [1, 2, 3] [1, 3, 2] [2, 1, 3] [2, 3, 1] [3, 1, 2] [3, 2, 1] ...