%I #93 Jul 19 2024 08:48:30
%S 0,0,1,1,2,1,3,2,2,3,3,2,4,3,3,2,5,4,3,3,3,5,5,2,5,3,5,5,3,3,5,6,5,3,
%T 5,2,5,7,5,4,4,5,5,3,7,5,5,3,6,6,3,7,7,3,5,3,5,7,7,6,4,5,7,2,5,5,9,7,
%U 3,5,5,6,7,5,5,5,9,5,3,5,6,7,7,4,8,5,7,7,3,5,5,5,7,9,9,1,7,8,5,4,5,7,7,7,9
%N Number of anti-divisors of n.
%C Anti-divisors are the numbers that do not divide a number by the largest possible margin. E.g. 20 has anti-divisors 3, 8 and 13. An alternative name for anti-divisor is unbiased non-divisors.
%C Definition: If an odd number i in the range 1 < i <= n divides N where N is any one of 2n-1, 2n or 2n+1 then d = N/i is called an anti-divisor of n. The numbers 1 and 2 have no anti-divisors.
%C Equivalently, an anti-divisor of n is a number d in the range [2,n-1] which does not divide n and is either a (necessarily odd) divisor of 2n-1 or 2n+1, or a (necessarily even) divisor of 2n.
%C Thus an anti-divisor of n is an integer d in [2,n-1] such that n == (d-1)/2, d/2, or (d+1)/2 (mod d), the class of d being -1, 0, or 1, respectively.
%C k is an anti-divisor of n if and only if 1 < k < n and | (n mod k) - k/2 | < 1. - _Max Alekseyev_, Jul 21 2007
%C The number of even anti-divisors of n is one less than the number of odd divisors of n; specifically, all but the largest odd divisor multiplied by the power of two dividing 2n (i.e., 2^A001511(n)). For example, the odd divisors of 18 are 1, 3, and 9, so the even anti-divisors of 18 are 1*4 = 4 and 3*4 = 12. - _Franklin T. Adams-Watters_, Sep 11 2009
%C 2n-1 and 2n+1 are twin primes if and only if n has no odd anti-divisors (e.g., n=15 has no odd anti-divisors so 29 and 31 are twin primes). - _Jon Perry_, Sep 02 2012
%C Records are in A066464. - _Robert G. Wilson v_, Sep 03 2012
%H Diana Mecum and T. D. Noe, <a href="/A066272/b066272.txt">Table of n, a(n) for n = 1..10000</a>
%H Jon Perry, <a href="/A066272/a066272a.html">The Anti-divisor</a>.
%H Jon Perry, <a href="/A066272/a066272.html">The Anti-divisor: Even More Anti-Divisors</a>.
%F G.f.: Sum_{k>0} x^(3k) / (1 - x^(2k)) + (x^(3k+1) + x^(3k+2)) / (1 - x^(2k+1)). - _Franklin T. Adams-Watters_, Sep 11 2009
%F a(n) = A000005(2*n-1) + A000005(2*n+1) + A001227(n) - 5. - _Max Alekseyev_, Apr 27 2010
%F a(n) = Sum_{i=3..n} (i mod 2) * (3 + floor((2n-1)/i) - ceiling((2n-1)/i) + floor(2n/i) - ceiling(2n/i) + floor((2n+1)/i) - ceiling((2n+1)/i)). - _Wesley Ivan Hurt_, Aug 10 2014
%F Sum_{k=1..n} a(k) ~ (n/2) * (3*log(n) + 6*gamma - 13 + 7*log(2)), where gamma is Euler's constant (A001620). - _Amiram Eldar_, Jan 19 2024
%e For example, n = 18: 2n-1, 2n, 2n+1 are 35, 36, 37 with odd divisors > 1 {5,7,35}, {3,9}, {37} and quotients 7, 5, 1, 12, 4, 1, so the anti-divisors of 18 are 4, 5, 7, 12. Therefore a(18) = 4.
%p antidivisors := proc(n)
%p local a,k;
%p a := {} ;
%p for k from 2 to n-1 do
%p if abs((n mod k)- k/2) < 1 then
%p a := a union {k} ;
%p end if;
%p end do:
%p a ;
%p end proc:
%p A066272 := proc(n)
%p nops(antidivisors(n)) ;
%p end proc:
%p seq(A066272(n),n=1..120); # _R. J. Mathar_, May 24 2010
%t antid[ n_ ] := Select[ Union[ Join[ Select[ Divisors[ 2n - 1 ], OddQ[ # ] && # != 1 & ], Select[ Divisors[ 2n + 1 ], OddQ[ # ] && # != 1 & ], 2n / Select[ Divisors[ 2n ], OddQ[ # ] && # != 1 & ] ] ], # < n & ]; Table[ Length[ antid[ n ] ], {n, 1, 100} ]
%t f[n_] := Length@ Complement[ Sort@Join[ Select[ Union@ Flatten@ Divisors[{2 n - 1, 2 n + 1}], OddQ@ # && # < n &], Select[ Divisors[2 n], EvenQ@ # && # < n &]], Divisors@ n]; Array[f, 105] (* _Robert G. Wilson v_, Jul 17 2007 *)
%t nd[n_]:=Count[Range[2,n-1],_?(Abs[Mod[n,#]-#/2]<1&)]; Array[nd,110] (* _Harvey P. Dale_, Jul 11 2012 *)
%o (PARI) al(n)=Vec(sum(k=1,n,(x^(3*k)+x*O(x^n))/(1-x^(2*k))+(x^(3*k+1)+x^(3*k+2)+x*O(x^n))/(1-x^(2*k+1)))) \\ _Franklin T. Adams-Watters_, Sep 11 2009
%o (PARI) a(n) = if(n>1, numdiv(2*n+1) + numdiv(2*n-1) + numdiv(n/2^valuation(n,2)) - 5, 0) \\ _Max Alekseyev_, Apr 27 2010
%o (PARI) antidivisors(n)=select(t->n%t && t<n, concat(concat(divisors(2*n-1),divisors(2*n+1)), 2*divisors(n)))
%o a(n)=#antidivisors(n) \\ _Charles R Greathouse IV_, May 12 2016
%o (Python)
%o from sympy import divisors
%o def A066272(n):
%o return len([d for d in divisors(2*n) if n > d >=2 and n%d]) + len([d for d in divisors(2*n-1) if n > d >=2 and n%d]) + len([d for d in divisors(2*n+1) if n > d >=2 and n%d]) # _Chai Wah Wu_, Aug 11 2014
%Y Cf. A000005, A058838, A066464, A066241, A001227, A001511, A001620, A066417.
%Y See A130799 for the anti-divisors.
%K nonn,easy
%O 1,5
%A _N. J. A. Sloane_, Dec 31 2001
%E More terms from _Robert G. Wilson v_, Jan 02 2002
%E More terms from _Max Alekseyev_, Apr 27 2010