Define H(m,n) for m≥n≥0 by
H(m,n)=1, if n≤1
H(m,n)=Σi=1..nH(m-i,minimum(i,m-i)), if n>1
For any integer k>0, what do you think H(k,k) represents?
In the table below, I don't show a column for n=1 as those are all 1's. Numbers over 999 are left blank to avoid abutting adjacent numbers.
m\n 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
0
1
2 2
3 2 3
4 3 4 5
5 3 5 6 7
6 4 7 9 10 11
7 4 8 11 13 14 15
8 5 10 15 18 20 21 22
9 5 12 18 23 26 28 29 30
10 6 14 23 30 35 38 40 41 42
11 6 16 27 37 44 49 52 54 55 56
12 7 19 34 47 58 65 70 73 75 76 77
13 7 21 39 57 71 82 89 94 97 99 100 101
14 8 24 47 70 90 105 116 123 128 131 133 134 135
15 8 27 54 84 110 131 146 157 164 169 172 174 175 176
16 9 30 64 101 136 164 186 201 212 219 224 227 229 230 231
17 9 33 72 119 163 201 230 252 267 278 285 290 293 295 296 297
18 10 37 84 141 199 248 288 318 340 355 366 373 378 381 383 384 385
19 10 40 94 164 235 300 352 393 423 445 460 471 478 483 486 488 489 490
20 11 44 108 192 282 364 434 488 530 560 582 597 608 615 620 623 625 626 627
21 11 48 120 221 331 436 525 598 653 695 725 747 762 773 780 785 788 790 791
22 12 52 136 255 391 522 638 732 807 863 905 935 957 972 983 990 995 998
23 12 56 150 291 454 618 764 887 984
24 13 61 169 333 532 733 919
25 13 65 185 377 612 860
26 14 70 206 427 709
27 14 75 225 480 811
28 15 80 249 540 931
29 15 85 270 603
30 16 91 297 674
31 16 96 321 748
32 17 102 351 831
33 17 108 378 918
34 18 114 411
35 18 120 441
36 19 127 478
37 19 133 511
38 20 140 551
39 20 147 588
40 21 154 632
The sequence of H(k,k) is:
1 2 3 5 7 11 15 22 30 42 56 77 101 135 176 231 297 385 490 627 792 1002 1255 1575 1958 2436 3010 3718 4565 5604 ...
DECLARE FUNCTION h# (m#, n#)
CLEAR , , 9999
DEFDBL A-Z
CLS
FOR m = -1 TO 40
IF m > -1 THEN PRINT USING "##"; m; : ELSE PRINT " ";
max = 20: IF max > m THEN max = m
IF m = -1 THEN max = 20
FOR n = 2 TO max
IF m > -1 THEN
v = h(m, n)
IF v < 1000 THEN
PRINT USING "####"; v;
END IF
ELSE
PRINT USING "####"; n;
END IF
NEXT
PRINT
NEXT
PRINT
FOR k = 1 TO 30: PRINT h(k, k); : NEXT: PRINT
FUNCTION h (m, n)
IF n > m OR m < 0 OR n < 0 THEN
REM
END IF
IF n <= 1 THEN h = 1: EXIT FUNCTION
t = 0
FOR i = 1 TO n
IF m - i < i THEN
j = m - i
ELSE
j = i
END IF
t = t + h(m - i, j)
NEXT i
h = t
END FUNCTION
|
Posted by Charlie
on 2005-09-09 15:07:15 |