Re: Concatenation of prime factors of numbers
- To: mathgroup at smc.vnet.net
- Subject: [mg78672] Re: Concatenation of prime factors of numbers
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Fri, 6 Jul 2007 03:33:41 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <f6i940$1mj$1@smc.vnet.net>
Diana wrote: > Can someone help me with this trick? > > I would like to create the following sequence, based on FactorInteger: > > 2,3,22,5,23,7,222,33,25,11,223,13,27,35,2222, ... > > where each term is the concatenation of the prime factors of n. > > Thanks, > > Diana Hi Diana, The following expressions will do what you are looking for: In[1]:= expnd[{fac_, exp_}] := StringJoin @@ Table[ToString[fac], {exp}] concat[lst_] := ToExpression[StringJoin[expnd /@ lst]] seq = Table[FactorInteger[n], {n, 2, 16}]; concat /@ seq Out[4]= {2, 3, 22, 5, 23, 7, 222, 33, 25, 11, 223, 13, 27, 35, 2222} Regards, Jean-Marc