MathGroup Archive 2007

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

Search the Archive

Re: How do quickest

  • To: mathgroup at smc.vnet.net
  • Subject: [mg72935] Re: How do quickest
  • From: dh <dh at metrohm.ch>
  • Date: Thu, 25 Jan 2007 07:55:38 -0500 (EST)
  • References: <200701231003.FAA06815@smc.vnet.net> <ep7cho$bdl$1@smc.vnet.net>


Hi Arthur,

Instead of searching for a solution inside the While loop, it is much 

faster ()but a bit more cumbersome to use Reduce. E.g.:

a={3};

For[k=1+a[[Length[a]]],Length[a]<10,

   s2=Sum[(a[[t]])^2,{t,1,Length[a]}]; 

t=Reduce[{y^2+s2\[Equal]x^2,x>0,y>=k},{y,x},Integers][[1]];

   t=t/.{Equal->Rule,And->List};

   k=y/.t;

   AppendTo[a,k]];

a



Artur wrote:

> How do quickest following very slowly procedure:

> a = {3}; For[k = 1 + a[[Length[

>      a]]], Length[a] < 13, While[! IntegerQ[Sqrt[(k)^2 + Sum[(a[[t]])^2,  

> {t, 1,

>     Length[a]}]]], k++]; AppendTo[a, k]]; a

> 

> ARTUR

> 



  • Prev by Date: Re: how to quickly read a >10MB big file
  • Next by Date: Re: How to remove Dot?
  • Previous by thread: How do quickest
  • Next by thread: Re: Re: How do quickest