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.

Showing 1-3 of 3 results.

A071321 Alternating sum of all prime factors of n; primes nondecreasing, starting with the least prime factor: A020639(n).

Original entry on oeis.org

0, 2, 3, 0, 5, -1, 7, 2, 0, -3, 11, 3, 13, -5, -2, 0, 17, 2, 19, 5, -4, -9, 23, -1, 0, -11, 3, 7, 29, 4, 31, 2, -8, -15, -2, 0, 37, -17, -10, -3, 41, 6, 43, 11, 5, -21, 47, 3, 0, 2, -14, 13, 53, -1, -6, -5, -16, -27, 59, -2, 61, -29, 7, 0, -8
Offset: 1

Views

Author

Reinhard Zumkeller, May 18 2002

Keywords

Comments

a(n) = 0 iff n square, a(A000290(n)) = 0;
a(n) <= 0 iff A001222(n) is even;
a(n) = n iff n prime, a(A000040(n)) = A000040(n).
a(2n) = -a(n) + 2. - Ralf Stephan

Examples

			72 = 2*2*2*3*3, therefore a(72) = 2 - 2 + 2 - 3 + 3 = 2;
90 = 2*3*3*5, therefore a(90) = 2 - 3 + 3 - 5 = -3.
		

Crossrefs

Programs

  • Haskell
    a071321 1 = 0
    a071321 n = sum $ zipWith (*) a033999_list $ a027746_row n
    -- Reinhard Zumkeller, Jun 01 2013
    
  • Mathematica
    Join[{0},Table[Total[Times@@@Partition[Riffle[Flatten[Table[#[[1]],{#[[2]]}]&/@ FactorInteger[n]],{1,-1},{2,-1,2}],2]],{n,2,100}]] (* Harvey P. Dale, Sep 23 2015 *)
  • Python
    from sympy import factorint
    def A071321(n):
        fs = factorint(n,multiple=True)
        return sum(fs[::2])-sum(fs[1::2]) # Chai Wah Wu, Aug 23 2021

Formula

a(n) = -A071322(n)*A008836(n). - Franklin T. Adams-Watters, Oct 18 2006

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

Original entry on oeis.org

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, 18, 28, 22, 30, 21, 24, 18, 32, 25, 36, 20, 28, 24, 40, 32, 42, 30, 36, 24, 46, 32, 43, 31, 36, 36, 52, 40, 48, 38, 40, 30, 58, 40, 60, 32, 46, 43, 56, 48, 66, 48, 48, 42, 70, 49, 72
Offset: 1

Views

Author

Reinhard Zumkeller, May 18 2002, Jul 03 2008

Keywords

Comments

Alternating row sums of A056538. - Omar E. Pol, Feb 17 2024
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

Examples

			Divisors of 20: {1,2,4,5,10,20} therefore a(20) = 20 - 10 + 5 - 4 + 2 - 1 = 12.
		

Crossrefs

Cf. A000010, A000203, A071322, a(n) = abs(A071323(n)).
Cf. A056538.

Programs

  • Maple
    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
  • Mathematica
    a[n_] := Plus @@ (-(d = Divisors[n])*(-1)^(Range[Length[d],1,-1])); Array[a, 100] (* Amiram Eldar, Mar 11 2020 *)
    Table[Total[Times@@@Partition[Riffle[Reverse[Divisors[n]],{1,-1},{2,-1,2}],2]],{n,80}] (* Harvey P. Dale, Nov 06 2022 *)
  • PARI
    a(n) = my(d=Vecrev(divisors(n))); sum(k=1, #d, (-1)^(k+1)*d[k]); \\ Michel Marcus, Aug 11 2018
    (APL, Dyalog dialect)
    divisors ← {⍺←⍵{(0=⍵|⍺)/⍵}⍳⌊⍵*÷2 ⋄ 1=⍵:⍺ ⋄ ⍺,(⍵∘÷)¨(⍵=(⌊⍵*÷2)*2)↓⌽⍺}
    A071324 ← {-/⌽(divisors ⍵)} ⍝ Antti Karttunen, Feb 16 2024
    
  • Python
    from sympy import divisors;  from functools import lru_cache
    cached_divisors = lru_cache()(divisors)
    def a(n):  return sum(d if i%2==0 else -d for i, d in enumerate(reversed(cached_divisors(n))))
    A071324 = [a(i) for i in range(1, 74)]  # Jwalin Bhatt, Apr 02 2025

Formula

a(A028983(n)) mod 2 = 0; a(A028982(n)) mod 2 = 1.
a(n) = Sum_{i=1..n} (A135539(n,i) mod 2). - Ridouane Oudra, Nov 23 2022
From Shreyansh Jaiswal, Apr 16 2025: (Start)
a(p) = p-1 for prime p.
For odd n, 2n/3 <= a(n) <= n.
For even n, n/2 <= a(n) <= 5n/6.
a(n) >= A000010(n) for n>=1. (End)

A370681 a(n) is the alternating sum of the unitary divisors of n, when these divisors are starting with n and decreasing.

Original entry on oeis.org

1, 1, 2, 3, 4, 4, 6, 7, 8, 6, 10, 10, 12, 8, 12, 15, 16, 10, 18, 18, 16, 12, 22, 18, 24, 14, 26, 24, 28, 22, 30, 31, 24, 18, 32, 30, 36, 20, 28, 36, 40, 32, 42, 36, 40, 24, 46, 34, 48, 26, 36, 42, 52, 28, 48, 54, 40, 30, 58, 46, 60, 32, 60, 63, 56, 48, 66, 54
Offset: 1

Views

Author

Amiram Eldar, Feb 26 2024

Keywords

Comments

a(n) is odd if and only if n is a power of 2.

Examples

			The unitary divisors of 6 are {1, 2, 3, 6}, hence a(6) = 6 - 3 + 2 - 1 = 4.
The unitary divisors of 12 are {1, 3, 4, 12}, hence a(12) = 12 - 4 + 3 - 1 = 10.
		

Crossrefs

Programs

  • Mathematica
    a[n_] := Module[{d = Reverse[Select[Divisors[n], CoprimeQ[#, n/#] &]]}, Total[(-1)^(Range[Length[d]] + 1)*d]]; Array[a, 100]
  • PARI
    a(n) = {my(d = Vecrev(select(x->(gcd(x, n/x) == 1), divisors(n)))); sum(i=1, #d, (-1)^(i+1)*d[i]);}

Formula

a(n) = A071324(n) if n is squarefree (A005117) or if n is in A370683.
Showing 1-3 of 3 results.