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.

A340740 a(n) is the sum of all the remainders when n is divided by positive integers less than n/2 and coprime to n.

Original entry on oeis.org

0, 0, 0, 0, 1, 0, 2, 2, 2, 1, 7, 2, 7, 6, 5, 4, 15, 7, 19, 10, 9, 8, 32, 9, 20, 20, 28, 13, 46, 14, 47, 31, 27, 31, 48, 17, 62, 39, 58, 26, 87, 26, 94, 53, 52, 41, 127, 48, 100, 65, 79, 61, 154, 52, 105, 62, 90, 80, 200, 45, 180, 113, 138, 103, 162, 77, 229, 116, 149, 73, 274, 87, 257, 166, 178
Offset: 1

Views

Author

J. M. Bergot and Robert Israel, Jan 18 2021

Keywords

Examples

			For n = 11, a(11) = (11 mod 1)+(11 mod 2)+(11 mod 3)+(11 mod 4)+(11 mod 5) = 7.
		

Crossrefs

Cf. A067439.

Programs

  • Maple
    f:= proc(n) local k;
      add(`if`(igcd(k,n)=1, n mod k, 0),k=1..floor(n/2))
    end proc:
    map(f, [$1..100]);
  • Mathematica
    Table[Sum[Mod[n, i]*Floor[1/GCD[i, n]], {i, Floor[(n - 1)/2]}], {n,
    100}] (* Wesley Ivan Hurt, Jan 18 2021 *)
  • PARI
    a(n) = sum(k=1, n\2, if (gcd(k, n)==1, n%k)); \\ Michel Marcus, Jan 18 2021
    
  • Python
    from math import gcd
    def A340740(n): return sum(n % k for k in range(1,n//2+1) if gcd(k,n) == 1) # Chai Wah Wu, Mar 18 2021

Formula

a(n) = Sum_{k=1..floor((n-1)/2)} (n mod k) * floor(1/gcd(n,k)). - Wesley Ivan Hurt, Jan 18 2021