I like that solution. Here is another approach

   4 p.~(2&^@>: ,.~ _1r3 * 2&^@>: + _1&^)i. 10
7 15 29 59 117 235 469 939 1877 3755

I found this by composing the linear poly's and noting the constant terms satisfy a two step recursion with eigenvalues 2 and _1.

   lc=.({.@[+{:@[*{.@]),*&{:
   lc/\.(7$_1 2,:1 2)
_43 128
_21  64
_11  32
 _5  16
 _3   8
 _1   4
 _1   2


On 11/27/2018 11:06 AM, Raul Miller wrote:
Sure, ... that's a bit bulkier than I prefer, but it works.

Here's another alternative:

    evenodd=: , (_1 2,:_1 4)&p.@{:
    evenodd evenodd 4
4 7 15 29 59

Thanks,

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to