The anti-divisors are numbers that do not divide a given number by the largest possible margin, and they can be found following a simple set of rules:
n is checked.n.n * 2 - 1 or n * 2 + 1 it's an anti-divisor.n * 2, it's an anti-divisor.Given an integer n, implement a function that returns an array containing the anti-divisors of n sorted in ascending order.
antiDivisors(10) β [3, 4, 7]
// 3 is a divisor of 21 (10 * 2 + 1)
// 4 is a divisor of 20 (10 * 2)
// 7 is a divisor of 21
antiDivisors(12) β [5, 8]
// 5 is a divisor of 25 (12 * 2 + 1)
// 8 is a divisor of 24 (12 * 2)
antiDivisors(20) β [3, 8, 13]
// 3 is a divisor of 39 (20 * 2 - 1)
// 8 is a divisor of 40 (20 * 2)
// 13 is a divisor of 39
The given n can be any integer, either positive, negative or 0.