[seqfan] Re: %N A028387 Numbers of form n+(n+1)^2 (?)

zak seidov zakseidov at yahoo.com
Sun Jul 4 04:07:08 CEST 2010


And this code is unneccessarily complicated too:

Table[Numerator[((n + 1)! - (n - 1)!)/(n!)], {n, 1, 30}]

--- On Sat, 7/3/10, Peter Pein <petsie at dordos.net> wrote:

From: Peter Pein <petsie at dordos.net>
Subject: [seqfan] Re: %N A028387  Numbers of form n+(n+1)^2 (?)
To: seqfan at list.seqfan.eu
Date: Saturday, July 3, 2010, 1:03 PM

Am Sat, 3 Jul 2010 06:32:29 -0700 (PDT)
schrieb zak seidov <zakseidov at yahoo.com>:

> Why not simply a(n)=n+(n+1)^2 (?).
> Zak
> 
> 
> 
>       
> 
> _______________________________________________
> 
> Seqfan Mailing list - http://list.seqfan.eu/
I agree it should read _all_ numbers of form n + (n+1)^2 or what you
suggested.

 And I do not understand why the (last) Mma-Program is so
complicated:

s = 1; lst = {s}; Do[s += n + 3; AppendTo[lst, s], {n, 1, 100, 2}]; lst
instead of 
FoldList[Plus[##, 3] &, 1, Range[1, 99, 2]] (without side-effects)
(and it is ~1200 times faster (for 27162 elements))

Peter

P.S.:
In[10]:=
s=1;lst={s};Do[s+=n+3;AppendTo[lst,s],{n,1,54321,2}];lst;//Timing
Out[10]= {36.39,Null}
 In[11]:=
lst2=FoldList[Plus[##,3]&,1,Range[1,54321,2]];//Timing Out[11]=
{0.03,Null}
In[12]:= lst===lst2
Out[12]= True
In[13]:= 36.39/0.03
Out[13]= 1213.
In[14]:= Length[lst]
Out[14]= 27162


_______________________________________________

Seqfan Mailing list - http://list.seqfan.eu/



      


More information about the SeqFan mailing list