Number of Self-Divisible Permutations

A permutation of the 1-indexed array nums = [1, 2, ..., n] is self-divisible when, for every position i with 1 <= i <= n, at least one of the following holds: the value at position i is divisible by i, or i is divisible by the value at position i. Given n, return the number of self-divisible permutations of [1, 2, ..., n].

Examples
Input: 1
Output: 1
Hints

Number of Self-Divisible Permutations

A permutation of the 1-indexed array `nums = [1, 2, ..., n]` is self-divisible when, for every position `i` with `1 <= i <= n`, at least one of the following holds: the value at position `i` is divisible by `i`, or `i` is divisible by the value at position `i`. Given `n`, return the number of self-divisible permutations of `[1, 2, ..., n]`.