Tap here to switch tabs
Problem
Submissions

Problem: Number of Self-Divisible Permutations

med
30 min
Try to solve the Number of Self-Divisible Permutations problem.

Statement

Given an integer n, consider a 11 indexed array nums representing a permutation of the integers from 11 to n.

A permutation nums is defined as self divisible if gcd⁡(\gcd(nums[i], i)=1) = 1 for every index i satisfying 1≤1 \le i ≤\le n, where gcd⁡(a,b)\gcd(a, b) denotes the greatest common divisor of aa and bb.

Return the total number of self divisible permutations of length n.

Constraints:

  • 1≤1 \le n ≤12\le 12

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Self-Divisible Permutations

med
30 min
Try to solve the Number of Self-Divisible Permutations problem.

Statement

Given an integer n, consider a 11 indexed array nums representing a permutation of the integers from 11 to n.

A permutation nums is defined as self divisible if gcd⁡(\gcd(nums[i], i)=1) = 1 for every index i satisfying 1≤1 \le i ≤\le n, where gcd⁡(a,b)\gcd(a, b) denotes the greatest common divisor of aa and bb.

Return the total number of self divisible permutations of length n.

Constraints:

  • 1≤1 \le n ≤12\le 12