Exemplo n.º 1
0
        private static int TopDown(int n)
        {
            int[] counts = new int[n + 1];
            counts[0] = 1;

            return(TripleStep.TopDown(n, counts));
        }
Exemplo n.º 2
0
        private static int TopDown(int n, int[] counts)
        {
            if (n < 0)
            {
                return(0);
            }

            if (counts[n] == 0)
            {
                counts[n] = TripleStep.TopDown(n - 1, counts)
                            + TripleStep.TopDown(n - 2, counts)
                            + TripleStep.TopDown(n - 3, counts);
            }

            return(counts[n]);
        }