login
a(n) = m*(m+1)/n, where A344005(n) is the smallest number m such that n divides m*(m+1).
2

%I #15 Jun 04 2021 22:23:24

%S 2,1,2,3,4,1,6,7,8,2,10,1,12,3,2,15,16,4,18,1,2,5,22,3,24,6,26,2,28,1,

%T 30,31,4,8,6,2,36,9,4,6,40,1,42,3,2,11,46,5,48,12,6,3,52,13,2,1,6,14,

%U 58,4,60,15,12,63,10,2,66,4,8,3,70,1,72,18,8,5,6,2,78,3,80,20,82,5

%N a(n) = m*(m+1)/n, where A344005(n) is the smallest number m such that n divides m*(m+1).

%C a(n) = n-1 if n is a prime power. - _Chai Wah Wu_, Jun 04 2021

%H Jon E. Schoenfield, <a href="/A344006/b344006.txt">Table of n, a(n) for n = 1..10000</a>

%o (PARI) a(n) = for(m=1, oo, if((m*(m+1))%n==0, return(m*(m+1)/n))) \\ _Felix Fröhlich_, Jun 04 2021

%o (Python 3.8+)

%o from itertools import combinations

%o from math import prod

%o from sympy import factorint

%o from sympy.ntheory.modular import crt

%o def A344006(n):

%o if n == 1:

%o return 2

%o plist = [p**q for p, q in factorint(n).items()]

%o if len(plist) == 1:

%o return n-1

%o else:

%o m = int(min(min(crt([m,n//m],[0,-1])[0],crt([n//m,m],[0,-1])[0]) for m in (prod(d) for l in range(1,len(plist)//2+1) for d in combinations(plist,l))))

%o return m*(m+1)//n # _Chai Wah Wu_, Jun 04 2021

%Y Cf. A011772, A061782, A344005.

%K nonn

%O 1,1

%A _N. J. A. Sloane_, Jun 04 2021