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.

A235342 Sum of exponents in the (unique) factorization of n as a ratio of p! terms, p prime.

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