Can This Be Made Cleaner

*To*: mathgroup at smc.vnet.net*Subject*: [mg29797] Can This Be Made Cleaner*From*: Flip at safebunch.com*Date*: Tue, 10 Jul 2001 20:25:33 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

Hello, I would like to move the sequence into the module and would like to add a max parameter to give up by (for example, if it doesn't find d by some time, print out cold not converge after max iterations). Can this be made easier, cleaner and faster with the sequence embedded within the module and it progresses the module one step at a time until it finds the appropriate D. Does it make sense to do it this way? Here is the short code. In[37]:= Clear[a] In[38]:= a[1] =5; In[39]:= a[n_]:= a[n] = (-1)^(n+1) (Abs[a[n-1]]+2) In[40]:= (*find the first D in a[n] for which JS[a,n] = -1 *) In[41]:= findD[a_,b_]:=Module[{n=a, lst=b}, i=1; While[JacobiSymbol[lst[[i]],n] != -1, i++];lst[[i]]] In[56]:= num=3559713579543216731; In[52]:= c=Table[a[n],{n,1,100}]; In[57]:= findD[num,c] Out[57]= -7 Thank you for any inputs ... Wilson