Count Divisible Permutations

SDE-1

Suppose you have n integers from 1 through n. A permutation of those n integers is considered a Divisible Permutation if for every i, where 1 <= i <= n, either of the following is true:

  • perm[i] is divisible by i.
  • i is divisible by perm[i].

Given an integer n, find the total number of the valid Divisible Permutations.

Note - you may want to refer to LC 810

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: