Skip to content

Commit 7a34422

Browse files
authored
Fix self-divisible condition using gcd function
1 parent a7269c3 commit 7a34422

File tree

1 file changed

+1
-1
lines changed
  • solution/2900-2999/2992.Number of Self-Divisible Permutations

1 file changed

+1
-1
lines changed

solution/2900-2999/2992.Number of Self-Divisible Permutations/Solution2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ def selfDivisiblePermutationCount(self, n: int) -> int:
55
for mask in range(1 << n):
66
i = mask.bit_count()
77
for j in range(1, n + 1):
8-
if (mask >> (j - 1) & 1) == 1 and (i % j == 0 or j % i == 0):
8+
if (mask >> (j - 1) & 1) == 1 and gcd(i, j) == 1:
99
f[mask] += f[mask ^ (1 << (j - 1))]
1010
return f[-1]

0 commit comments

Comments
 (0)