MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Can This Be Made Cleaner

  • To: mathgroup at smc.vnet.net
  • Subject: [mg29811] Re: [mg29797] Can This Be Made Cleaner
  • From: Ranko Bojanic <bojanic at math.ohio-state.edu>
  • Date: Wed, 11 Jul 2001 01:27:00 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com



Wilson wrote in [mg29797]:
> 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



Wilson:

If you have any list of integers aLst and any integer N, then the following line

                     Select[aLst, (JacobiSymbol[#, N] == -1)&]
                     
will give you the list of all elements m of aLst such that JacobiSymbol[m,N]==-1
If no such elements exist, it will return the empty list { }.

Regards,
Ranko

PS. The sequence a[n] is really the sequence (-1)^(n+1)*(2n + 3), n = 1,2,3,...


  • Prev by Date: Re: Opening Directory
  • Next by Date: Re: Rotating tick marks
  • Previous by thread: Can This Be Made Cleaner
  • Next by thread: Re: Can This Be Made Cleaner