Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

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

Search the Archive

Re: Changing Pure Function in Module

  • To: mathgroup at
  • Subject: [mg29842] Re: [mg29822] Changing Pure Function in Module
  • From: Ranko Bojanic <bojanic at>
  • Date: Fri, 13 Jul 2001 04:19:22 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

Hi Wilson:
Now that we know exactly what you want, it is easy to write a module for FindD:

FindD[n_]:=Module[{c=1,a},If[IntegerQ[Sqrt[n]],a="n is a perfect square",                           
n is a perfect square



In Message 42/124 From Flip at Jul 12,01 02:52:35 AM-0400
Wilson wrote:

> Hi All,
> thank you to all who continue to respond to all of my questions ... and there
> are always plenty of them.
> I have the following function embedded in the findD code below.
> a[1] =5;
> a[n_]:= a[n] = (-1)^(n+1) (Abs[a[n-1]]+2)
> In[225]:=
> findD[n_]:=
> Module[{c=0},NestWhile[(c++;(-1)^c(Abs[#]+2))&,5,JacobiSymbol[#,n]!=-1&]]
> I would like to change the pure function to use the following (cleaner) function
> that requires no starting value (and starts for n = 1).
> In[255]:=
> a[n_]:= a[n]= (-1)^(n+1)*(2n + 3)
> Also, it would be important to test n prior to calling findD.  If n is a perfect
> square, findD will "never" converge.  Is there a simple way to test if n is
> square and tell the user ... try again ... n is a perfect square.
> Again thank you for all of the help ... Wilson

  • Prev by Date: Re: Logic and Truth Tables with Mathematica?
  • Next by Date: Re: Naming pieces of patterns
  • Previous by thread: Re: Changing Pure Function in Module
  • Next by thread: Comparison of Mathematica on Various Computers