Student Support Forum: 'How to create a table of the number of steps?' topicStudent Support Forum > General > "How to create a table of the number of steps?"

 < Previous Comment | Next Comment > Help | Reply To Comment | Reply To Topic
 Author Comment/Response Bill Simpson 09/21/12 6:30pm You have a list of things returned from FactorInteger and you want to do the same thing to each thing. That usually meanss "use Map." Each thing is {primefactor,howmany}. If you had Table[primefactor,{howmany}] this would be close to what you want. Push Map into doing this. Then use Flatten to merge all the sublists and Plus@@ to total the result. Now you want to repeatedly do a function to a result until the result stops changing and keep track of how many times you needed to do the function. Length of FixedPointList seems like a good choice. So In[1]:= ln[n_]:=Plus@@Flatten[Map[Table[First[#],{Last[#]}]&,FactorInteger[n]]]; Table[Length[FixedPointList[ln,i]]-1,{i,104}] Out[2]= {2,1,1,1,1,2,1,3,3,2,1,2,1,4,4,4,1,4,1,4,3,2,1,4,3,5,4,2,1,3,1,3,5,2,3,3,1,4,5,2,1,3,1,5,2,4,1,2,5,3,5,2,1,2,5,2,3,2,1,3,1,6,2,3,5,5,1,4,6,5,1,3,1,6,2,2,5,5,1,2,3,2,1,5,3,3,4,2,1,2,5,5,3,6,5,2,1,5,2,5,1,3,1,2} Compare that with A002217. URL: ,

 Subject (listing for 'How to create a table of the number of steps?') Author Date Posted How to create a table of the number of steps? Jared E 09/21/12 3:43pm Re: How to create a table of the number of steps? Bill Simpson 09/21/12 6:30pm Re: How to create a table of the number of steps? Peter Pein 09/24/12 01:51am
 < Previous Comment | Next Comment > Help | Reply To Comment | Reply To Topic