.


7 - 2


: k := k + 1; k- : p := 2*p + k; , p s 1 :

uncle(k, p, s + p, n - 1)

, , n 1.

 

Program Rich_man1; { rich man - }

uses WinCrt;

var

n : integer;

{---------------------------------------------------------------------------------------}

Procedure uncle(k, p, s, n : longint); {uncle - }

begin

if n = 1 then write(s)

else

begin

k := k + 1;

p := 2*p + k;

uncle(k, p, s + p, n - 1)

end

end;

{---------------------------------------------------------------------------------------}

begin

write(' '); readln(n);

write(' ', n, '- ');

uncle(1, 1, 1, n);

writeln(' ')

end.

, 100 . : if s >= 100 then write(n), .

Program Rich_man2;

uses WinCrt;

var

n : integer;

{----------------------------------------------------------------------------------------}

Procedure uncle1(k, p, s, n : longint);

begin

if s >= 100 then write(n)

else

begin

k := k + 1;

p := 2*p + k;

uncle1(k, p, s + p, n + 1)

end

end;

{--------------------------------------------------------------------------------------}

begin

write(' 100 ');

uncle1(1, 1, 1, 1);

writeln(' - ')

end.

, . .