      function cmb(n,r)
      implicit none
      integer :: cmb, n, r, i, j, C(0:33, 0:33)
c
      if (n > 33 .or. r > n) then
        cmb = 0
        return
      end if
c
      C(0, 0) = 1
      do i = 1, n
        C(i,0) = 1
        C(i,i) = 1
        do j = 1, i - 1
          C(i, j) = C(i - 1, j - 1) + C(i - 1, j)
        end do
      end do
c
      cmb = C(n, r)
      return
      end

