A365687 a(n) = number of fractions m/n, 0 <= m < n, gcd(m,n) = 1 whose partial fraction decomposition has integer part 0.
1, 1, 2, 2, 4, 1, 6, 4, 6, 2, 10, 2, 12, 3, 4, 8, 16, 3, 18, 4, 6, 5, 22, 4, 20, 6, 18, 6, 28, 0, 30, 16, 10, 8, 12, 6, 36, 9, 12, 8, 40, 1, 42, 10, 12, 11, 46, 8, 42, 10, 16, 12, 52, 9, 20, 12, 18, 14, 58, 2, 60, 15, 18, 32, 24, 1, 66, 16, 22, 2, 70, 12, 72, 18, 20
Offset: 1
Keywords
Examples
a(10) = 2 because, of the four nonnegative reduced fractions less than 1 with denominator 10, two of them (7/10 and 9/10) have integer part 0: 1/10 = -1 + 1/2 + 3/5 3/10 = -1 + 1/2 + 4/5 7/10 = 1/2 + 1/5 9/10 = 1/2 + 2/5.
Programs
-
SageMath
def a(n): b = n fs = factor(b) # bzList will hold Bezout coefficients to express 1/n as combination # of the reciprocals of the prime power factors of n. ppList will # hold the prime power factors themselves. bzList = [] bz0 = 1 ppList = [] for f in fs: q = f[0]^f[1] ppList.append(q) b = b / q bzThis = xgcd(q,b) bzList.append(bz0*bzThis[2]) bz0 = bz0 * bzThis[1] ct = 0 for j in n.coprime_integers(n): if sum(floor(j*bzList[i]/ppList[i])\ for i in range(len(ppList))) == 0: ct = ct + 1 return(ct)
Comments