sicp-ex-3.66



<< Previous exercise (3.65) | Index | Next exercise (3.67) >>


meteorgan



(1, 100) : 198
(100, 100): 99*2^200 - 1 + 2^99. 
the equation for (m, n) is: 
n = 1:   2^m - 1;
n = 2:   2^m - 1 + 2^(m-1);
n > 2:   2^m - 1 + 2^(m+1) + (n-2)*2^m
@meteorgan  ---  You are Wrong !!!
(1,100):198;
(100,100):2^100 - 1;
---------------
f(n,m) m>=n (m,n is Z+)
(m-n=0): 2^n - 1
(m-n=1): (2^n - 1) + 2^(n - 1)
(m-n>1): (2^n - 1) + 2^(n - 1) + (m - n - 1) * 2^n
------------------------------------
  1   2   3   4   5   6   7   8   9  ...  100   
1 1   2   4   6   8  10  12  14  16       198 
2     3   5   9  13  17  21  25  29        
3         7  11  19  27  35  43  51
4            15  23  39  .....
5                31  .........
.
.
100 ------------------------------------- (2^100 - 1)