function s = basketball_dynamic ( n )

%*****************************************************************************80
%
%% basketball_dynamic() counts the ways of getting any basketball score from 0 to N.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    31 January 2025
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer n: the highest score to be considered.
%
%  Output:
%
%    integer s(1:n+1): s(n+1) is the number of ways of achieving a score of n.
%
  s = zeros ( n + 1, 1 );

  s(1) = 1;
%
%  I is the score, ip1 is there the score is stored.
%
  for i = 1 : n

    ip1 = i + 1;

    if ( 1 <= i ) 
      s(ip1) = s(ip1) + s(ip1-1);
    end

    if ( 2 <= i ) 
      s(ip1) = s(ip1) + s(ip1-2);
    end

    if ( 3 <= i ) 
      s(ip1) = s(ip1) + s(ip1-3);
    end

  end

  return
end

