%I #27 Aug 30 2022 21:26:49
%S 0,1,0,2,-2,1,-1,3,0,-1,-2,2,-2,0,-2,4,-2,1,-1,0,-1,-1,2,3,-4,-1,0,1,
%T 1,-1,1,5,-2,-1,-3,2,-1,0,-2,1,1,0,0,0,-2,3,-1,4,-2,-3,-2,0,3,1,-4,2,
%U -1,2,0,0,0,2,-1,6,-4,-1,-2,0,2,-2,0,3,-3,0,-4,1,-3,-1,7,2,0,2,-4,1,-4,1,1,1,0,-1,-3,4,1,0,-3,5,-3,-1,-2,-2,5,-1,1
%N Sum of exponents in the (unique) factorization of n as a ratio of p! terms, p prime.
%C With n > 0, write n = p_1!p_2!...p_k!/(q_1!q2!...q_l!) where p_i,q_j are primes and the fraction is simplified (i.e., no p_i is a q_j). This representation is unique for positive integers (and positive rational numbers), so we let a(n):=#p_i! terms on top-#q_j! terms on bottom.
%H Antti Karttunen, <a href="/A235342/b235342.txt">Table of n, a(n) for n = 1..5040</a>
%H Seventieth Annual William Lowell Putnam Mathematical Competition, <a href="http://math.la.asu.edu/~checkman/2009PutnamQ.pdf">Problem B1</a>, (2009).
%F a(1)=0; a(p!)=1, p prime; a(xy)=a(x)+a(y); (group homomorphism from Q^+ to Z).
%e a(1)=0 (by convention).
%e a(2)=1 since 2=2!.
%e a(3)=0 since 3=3!/2!.
%e a(4)=2 since 4=2!*2!.
%e a(5)=-2 since 5=5!/(3!*2!*2!).
%o (Sage)
%o def plus(c, d, mult):
%o for elt in d:
%o if elt in c:
%o c[elt]+=mult*d[elt]
%o else:
%o c[elt]=mult*d[elt]
%o def rep(m):
%o if m==1:
%o return {}
%o if m==2:
%o return {2:1}
%o f=factor(Integer(m))
%o #print f
%o if len(f)==1 and f[0][1]==1:
%o #print "prime", m
%o p=prime_range(m)[-1]
%o new={m:1, p:-1}
%o r=range(p+1, m)
%o #print "range", r
%o for k in r:
%o plus(new, rep(k), -1)
%o else:
%o new={}
%o #print "not prime", m, f
%o for (p, mult) in f:
%o #print (p, mult)
%o plus(new, rep(p), mult)
%o for elt in [elt for elt in new if new[elt]==0]:
%o new.pop(elt)
%o return new
%o def weight(m):
%o w=0
%o r=rep(m)
%o for p in r:
%o w+=r[p]
%o return w
%o A235342=[weight(m) for m in range(1, 5041)]
%o # Above code "de-periodicized" by _Antti Karttunen_, Mar 28 2017
%o # This is just for outputting a b-file:
%o i=0
%o outfp = open('b235342.txt','w')
%o for an in A235342:
%o i = i+1
%o outfp.write(str(i) + " " + str(an) + "\n")
%o outfp.close()
%Y Cf. A001222, A236441.
%K sign
%O 1,4
%A _Alexander Riasanovsky_, Jan 06 2014
%E More terms from _Antti Karttunen_, Mar 28 2017
|