Re: help working with functions
- To: mathgroup at smc.vnet.net
- Subject: [mg60031] Re: [mg59987] help working with functions
- From: stephen layland <layland at wolfram.com>
- Date: Sun, 28 Aug 2005 23:14:43 -0400 (EDT)
- References: <200508270811.EAA15266@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
and thus spake hawkmoon269 [2005.08.27 @ 03:57]:
> I have the following program written:
>
> Clear[a]; Clear[seq];
> seq = Array[a,10,0]; a[0]=0; a[1]=1;
> Do[a[k] = a[k-1] + a[k-2] + 0 4^(k-2), {k,2,10}];
> seq
>
> It works fine and correctly outputs
>
> {0, 1, 1, 2, 3, 5, 8, 13, 21, 34}
>
> My sense,though, is that this is inelegant newbie code and am
> interested in hearing alternative ways to program with the same output.
You've already received several good methods, but I couldn't resist
sending the obvious specific case:
In[1]:= Fibonacci/@Range[0,9]
Out[1]= {0, 1, 1, 2, 3, 5, 8, 13, 21, 34}
It won't help you for your generic i j^(k-2) case, though.
--
/*------------------------------*\
| stephen layland |
| Documentation Programmer |
| http://members.wri.com/layland |
\*------------------------------*/
- References:
- help working with functions
- From: "hawkmoon269" <rson@new.rr.com>
- help working with functions