[Jprogramming] arithmetic sequence

Henry Rich HenryHRich at nc.rr.com
Wed Dec 19 12:54:32 UTC 2012


    next=.0 3+*&5
    20 next@]^:(i.@[) 1 0

Or,


    next=.5&(0 3 + *)
    (i. 20) next 1 0

Henry Rich

On 12/19/2012 6:46 AM, alessandro codenotti wrote:
>
> I have a sequence defined as:
>
> S(1)=K
> S(n+1)=3+5*S(n)
>
> where K is an integer constant
> so the first 4 terms of this sequence (in function of K) are:
> S(1)=K
> S(2)=5K+3
> S(3)=25K+18
> s(4)=125K+93
>
> representing every term with an array where the first element is the coefficent of K and the second is the other part is trivial to write the following verb to find the next term of the sequence:
>
>     next=.0 3+*&5
>     next 1 0
> 5 3
>     next 5 3
> 25 18
>     next 25 18
> 125 93
>
> but i have a problem writing a functions that returns an array of shape equals to N 2 where the n-th row contain the 2 coefficents of the n-th term of the sequence, can anyone help me doing that?
> Thank in advice!
>
>
>
>   		 	   		
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>


More information about the Programming mailing list