How to write a LAMBDA function in Excel for this recursive calculation
09:23 26 Jul 2022

I'm trying to come up with a LAMBDA formula that captures the following recursive calculation:

Column A has 40 rows with integers between 1 and 40. Column B divides each integer in column A by 6 and rounds it up. Column C divides each integer in column B by 6 and rounds it up. This continues until the integer is 1 or less, and then I want the sum of the full row for a given integer. So, for example, for the number 25 in column A, I get 6 (5 from column B and 1 from column C). For the number 40 in column A, I get 10 (7 from column B, 2 from column C, 1 from column D).

Is it possible to come up with a LAMBDA function that would get me the correct output for a given number in column A? I don't want to use VBA - just want to use the LAMBDA function for this.

Image of the XL

Data Column 1 Column 2 Column 3 Column 4 Sum
1 0 0 0 0 1
2 1 0 0 0 1
3 1 0 0 0 1
4 1 0 0 0 1
5 1 0 0 0 1
6 1 0 0 0 1
7 2 1 0 0 3
8 2 1 0 0 3
9 2 1 0 0 3
10 2 1 0 0 3
11 2 1 0 0 3
12 2 1 0 0 3
13 3 1 0 0 4
14 3 1 0 0 4
15 3 1 0 0 4
16 3 1 0 0 4
17 3 1 0 0 4
18 3 1 0 0 4
19 4 1 0 0 5
20 4 1 0 0 5
21 4 1 0 0 5
22 4 1 0 0 5
23 4 1 0 0 5
24 4 1 0 0 5
25 5 1 0 0 6
26 5 1 0 0 6
27 5 1 0 0 6
28 5 1 0 0 6
29 5 1 0 0 6
30 5 1 0 0 6
31 6 1 0 0 7
32 6 1 0 0 7
33 6 1 0 0 7
34 6 1 0 0 7
35 6 1 0 0 7
36 6 1 0 0 7
37 7 2 1 0 10
excel recursion excel-formula excel-lambda