A bridge hand consists of 13 cards, drawn from a pack of 52 cards with 13 in each of four suits.
Bridge hands can be classified by "shape". The shape of a hand is the set of lengths of the suits,
in order. Thus a hand with "6-4-3-0" shape might have three spades, no heart, six diamonds and
four clubs.

There are 39 shapes of bridge hand

There are 39 possible shapes of bridge hand. They are shown to the right.
You can click on the diagram to see a larger version.

The diagram shows the shapes in their "partial order" by flatness, as indicated by descending
green lines. Hand B is regarded as flatter than hand A if

Hand A can be converted to hand B by moving one card of hand A to another, shorter suit
or
Hand B is flatter than some hand which is flatter than hand A.

Note that this defintion is recursive.

How to calculate the number of shapes

To use a computer program to calculate the number of shapes of bridge hand, we can
use four nested loops. Or more elegantly, we can use the insight

A hand either has a void (so we have dealt with one of the suits)
or
it doesn't (so we have placed as many cards as there were suits)

to break the problem down into two smaller ones, and use double recursion.

This is written in Javascipt.
Very similar code can do the same calculation in any other recursive language.
If this function is called with suits=4 and cards=13, it returns the value 39.
It also works for other inputs. You can test it below.