Sylvester sequence in K

Hi,

I’m playing with K language and for excercise I’ve chosen to write Sylvester sequence [1] but got stucked.
I’ve written this sequence successfully in Haskell [2].

My tryout in K is this:

>  x: 2
2
>  s: {((s*x)+1)}
{((s*x)+1)}
>  1 s/ 1 2
type error
1 s/ 1 2

I know that I have written s function badly but don’t know how to do it correctly.

Thanks for help,

Vaclav

[1] https://en.wikipedia.org/wiki/Sylvester's\_sequence
[2] https://github.com/wencaaa/mathfun/blob/master/sylvester.hs

first 7 terms

q){x,1+prd x}/[6;2]

2 3 7 43 1807 3263443 10650056950807

see

http://code.kx.com/wiki/Reference/BackSlash

another approach

q){x,1+prd(2#last)-0 1}/[6;2]

2 3 7 43 1807 3263443 10650056950807

or:

q)s:{1+x*x-1}
q)6 s\ 2
2 3 7 43 1807 3263443 10650056950807