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.

A330492 a(n) = sum of second differences of the sorted divisors of n.

Original entry on oeis.org

0, 0, 1, 0, 2, 0, 3, 4, 4, 0, 5, 0, 6, 8, 7, 0, 8, 0, 9, 12, 10, 0, 11, 16, 12, 16, 13, 0, 14, 0, 15, 20, 16, 24, 17, 0, 18, 24, 19, 0, 20, 0, 21, 28, 22, 0, 23, 36, 24, 32, 25, 0, 26, 40, 27, 36, 28, 0, 29, 0, 30, 40, 31, 48, 32, 0, 33, 44, 34, 0, 35, 0, 36
Offset: 2

Views

Author

Michel Lagneau, Dec 16 2019

Keywords

Comments

The sums of the first differences of the divisors of n are given by the sequence b(n) = n - 1.
Let the set {D(i)} = {d(i + 1) - d(i)} where the d(i) are the divisors of an integer m listed in ascending order with i = 1, 2 , ..., tau(n)-1. The sequence is given by a(n) = Sum_{k = 1..tau(n)-2} (D(k + 1) - D(k)).

Examples

			a(12) = 5 because the divisors of 12 are {1, 2, 3, 4, 6, 12} and {D(i)} = {d(i+1)-d(i)} ={1, 1, 1, 2, 6}, Sum_{D(i), i = 1..4} {D(i+1)-D(i)} = 0 + 0 + 1 + 4 = 5.
		

Crossrefs

Programs

  • Maple
    with(numtheory):nn:=100:
    for n from 2 to nn do:
    d:=divisors(n):n0:=nops(d):T:=array(1..n0-1,[0$n0-1]):
      for j from 1 to n0-1 do:
       T[j]:=d[j+1]-d[j]:
      od:
       s:=sum(ā€˜T[i+1]-T[i] ’,ā€˜i’=1..n0-2): printf(`%d, `,s):
    od:
    *** alternative program using the formula ***
    with(numtheory):nn:=100:
    for n from 2 to nn do:
    d:=divisors(n):t:=tau(n):s:=d[t]-d[t-1]+d[1]-d[2] :
      printf(`%d, `,s):
    od:
  • Mathematica
    Array[Total@ Differences[Divisors@ #, 2] &, 73, 2] (* Michael De Vlieger, Dec 16 2019 *)
  • PARI
    a(n) = my(d=divisors(n)); d[#d] - d[#d-1] + d[1] - d[2]; \\ Michel Marcus, Feb 05 2020
    
  • Python
    from sympy import primefactors
    def a(n): p = primefactors(n)[0]; return (n//p - 1) * (p - 1)
    print([a(n) for n in range(2, 75)]) # Michael S. Branicky, Apr 04 2021

Formula

a(n) = d(tau(n)) - d(tau(n) - 1) + d(1) - d(2) where d(i) are the divisors of n.
a(prime(n)) = 0 and a(2k) = k-1, k = 1, 2, ...
a(p^2) = (p-1)^2 if p prime, with the generalization a(p^m) = (p-1)(p^(m-1) - 1).
a(n) = (n/p-1)*(p-1), where p is the least prime factor of n. - Nathaniel Gregg, Apr 04 2021