Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- KX Community
- :
- Discussion Forums
- :
- kdb+ and q
- :
- How to implement the recursion with 2 variables in...

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

How to implement the recursion with 2 variables included?

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

2020.07.29 05:04 PM

Hi,Masters:

I have a task to calculate a value, which includes 2variables and should be implemented with recursion restate.

The formula is simple: *F _{n} = F_{n-1} * 2+ A_{n }(Given conditions:F_{0} = 10, A = 1 + til 5)*

I implemented the part of “*Fn =Fn-1 * 2*“ in Q with “5 {x * 2}\ 10”, but I was blocked with the secondvariable. Do you have any comment? Appreciate for you advice.

Thanks

hzadonis

2 REPLIES 2

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

2020.07.30 08:57 PM

given function 'f' defined as:

f:{[F;A]A+F*2}

does this meet your requirement?

q)f\[10;til 5]

20 41 84 171 346

20 41 84 171 346

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

2020.07.30 11:31 PM

Thank you. Let me try your method.

I wrote a function and create a temp table to store array, then use a while loop to calculate values, not smart.

在2020年7月31日星期五 UTC+8 上午11:58:11<Nick> 写道：

given function 'f' defined as:f:{[F;A]A+F*2}does this meet your requirement?q)f\[10;til 5]

20 41 84 171 346

Main Office Contacts

**EMEA**

Tel: +44 (0)28 3025 2242

**AMERICAS**

Tel: +1 (212) 447 6700

**APAC**

Tel: +61 (0)2 9236 5700

Useful Information

Popular Links

Follow Us

KX. All Rights Reserved.

KX and kdb+ are registered trademarks of KX Systems, Inc., a subsidiary of FD Technologies plc.