PnnK

task22

Jul 18th, 2021
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.60 KB | None | 0 0
  1. function f(start_pos, curr_pos: integer): integer;
  2. begin
  3.     if curr_pos < start_pos then
  4.     begin
  5.         result := 0;
  6.     end
  7.     else if curr_pos = start_pos then
  8.     begin
  9.         result := 1;
  10.     end
  11.     else if curr_pos = 29 then
  12.     begin
  13.         result := 0;
  14.     end
  15.     else
  16.       begin
  17.         var k: integer;
  18.         k := f(start_pos, curr_pos - 1);
  19.         if curr_pos mod 2 = 0 then k += f(start_pos, curr_pos div 2);
  20.         if curr_pos mod 3 = 0 then k += f(start_pos, curr_pos div 3);
  21.         result := k;
  22.     end;
  23. end;
  24.  
  25.  
  26. begin
  27.     print(f(2, 13) * f(13, 44));
  28. end.
Advertisement
Add Comment
Please, Sign In to add comment