[seqfan] RE: list of factors [was: Maple question]

Emeric Deutsch deutsch at duke.poly.edu
Sun May 2 18:10:47 CEST 2004


Thanks to all of you. In addition to having your solutions, 
I also learn a lot about new possibilities (new to me). As I 
mentioned before, I came up with this solution:

f:=proc(n) a:=op(2,ifactors(n)): [seq(seq(a[i][1],
j=1..a[i][2]),i=1..nops(a))] end:   

I used this to write a Maple program that determines the number 
of nodes of the rooted tree having as Matula-Goebel number the 
positive integer n. 

I also needed the inverse of the ithprime function. I am afraid 
it is pretty clumsy. 

The entire Maple program is 

P:=[seq(ithprime(x),x=1..300)]: q:=proc(n) if member(n,P)=true then Q:={}:
for j from 1 to 300 do if P[j]<n then Q:=Q union {P[j]}; else 1+nops(Q);
fi od; elif n=1 then 1 else not prime fi; end: r:=proc(n)
a:=op(2,ifactors(n)): [seq(seq(a[i][1], j=1..a[i][2]),i=1..nops(a))] end:
g[1]:=1: for n from 2 to 500 do if isprime(n)=true then g[n]:=1+g[q(n)]
else r(n); a:=[seq(q(r(n)[i]),i=1..nops(r(n)))];
g[n]:=1+sum(g[a[j]],j=1..nops(a)) fi od: seq(g[n],n=1..108);
# q is the inverse of the ithprime function; r gives the not necessarily
distinct prime factors of a positive integer; there must be
a smarter way of doing this.

It is pretty clumsy and slow.   

Probably it will appear in a few days in the OEIS sequence # A061775.
You are invited to improve on it, submit it, and "have your name
immortalized" (courtesy of Neil Sloane). 

All the best and have at least half the fun I have with this,
Emeric 









More information about the SeqFan mailing list