cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A071324 Alternating sum of all divisors of n; divisors nonincreasing, starting with n.

This page as a plain text file.
%I A071324 #80 Jun 14 2025 00:15:11
%S A071324 1,1,2,3,4,4,6,5,7,6,10,8,12,8,12,11,16,13,18,12,16,12,22,16,21,14,20,
%T A071324 18,28,22,30,21,24,18,32,25,36,20,28,24,40,32,42,30,36,24,46,32,43,31,
%U A071324 36,36,52,40,48,38,40,30,58,40,60,32,46,43,56,48,66,48,48,42,70,49,72
%N A071324 Alternating sum of all divisors of n; divisors nonincreasing, starting with n.
%C A071324 Alternating row sums of A056538. - _Omar E. Pol_, Feb 17 2024
%C A071324 Does a constant analogous to the median abundancy index (see A353617) exist for this function? Particularly, does a constant exist such that the numbers having the value a(n)/n greater than this constant have natural density exactly 1/2? Using the first 10^7 values, one observes that if it exists, this constant appears to converge around 0.726. - _Shreyansh Jaiswal_, Apr 16 2025
%H A071324 Reinhard Zumkeller, <a href="/A071324/b071324.txt">Table of n, a(n) for n = 1..10000</a>
%H A071324 Krassimir Atanassov, <a href="https://nntdm.net/volume-15-2009/number-3/21-22/">A remark on an arithmetic function. Part 2</a>, Notes on Number Theory and Discrete Mathematics 15(3) (2009), 21-22.
%H A071324 Shreyansh Jaiswal, <a href="/A071324/a071324.pdf">On two Conjectures by Atanassov on the Alternating sum-of-divisors function</a>, Jun 11 2025
%F A071324 a(A028983(n)) mod 2 = 0; a(A028982(n)) mod 2 = 1.
%F A071324 a(n) = Sum_{i=1..n} (A135539(n,i) mod 2). - _Ridouane Oudra_, Nov 23 2022
%F A071324 From _Shreyansh Jaiswal_, Apr 16 2025: (Start)
%F A071324 a(p) = p-1 for prime p.
%F A071324 For odd n, 2n/3 <= a(n) <= n.
%F A071324 For even n, n/2 <= a(n) <= 5n/6.
%F A071324 a(n) >= A000010(n) for n>=1. (End)
%e A071324 Divisors of 20: {1,2,4,5,10,20} therefore a(20) = 20 - 10 + 5 - 4 + 2 - 1 = 12.
%p A071324 with(numtheory): a:=proc(n) local k, t:=0, A:=divisors(n); for k to tau(n) do t:= t+A[k]*(-1)^(tau(n)-k) end do; return t; end proc; seq(a(n), n=1..60); # _Ridouane Oudra_, Nov 23 2022
%t A071324 a[n_] := Plus @@ (-(d = Divisors[n])*(-1)^(Range[Length[d],1,-1])); Array[a, 100] (* _Amiram Eldar_, Mar 11 2020 *)
%t A071324 Table[Total[Times@@@Partition[Riffle[Reverse[Divisors[n]],{1,-1},{2,-1,2}],2]],{n,80}] (* _Harvey P. Dale_, Nov 06 2022 *)
%o A071324 (PARI) a(n) = my(d=Vecrev(divisors(n))); sum(k=1, #d, (-1)^(k+1)*d[k]); \\ _Michel Marcus_, Aug 11 2018
%o A071324 (APL, Dyalog dialect)
%o A071324 divisors ← {⍺←⍵{(0=⍵|⍺)/⍵}⍳⌊⍵*÷2 ⋄ 1=⍵:⍺ ⋄ ⍺,(⍵∘÷)¨(⍵=(⌊⍵*÷2)*2)↓⌽⍺}
%o A071324 A071324 ← {-/⌽(divisors ⍵)} ⍝ _Antti Karttunen_, Feb 16 2024
%o A071324 (Python)
%o A071324 from sympy import divisors;  from functools import lru_cache
%o A071324 cached_divisors = lru_cache()(divisors)
%o A071324 def a(n):  return sum(d if i%2==0 else -d for i, d in enumerate(reversed(cached_divisors(n))))
%o A071324 A071324 = [a(i) for i in range(1, 74)]  # _Jwalin Bhatt_, Apr 02 2025
%Y A071324 Cf. A000010, A000203, A071322, a(n) = abs(A071323(n)).
%Y A071324 Cf. A134871, A135539.
%Y A071324 Cf. A056538.
%K A071324 nonn
%O A071324 1,3
%A A071324 _Reinhard Zumkeller_, May 18 2002, Jul 03 2008