Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
How should I start coding this?
Posted
Updated 3-Dec-12 7:36am
v2
Comments
Sergey Alexandrovich Kryukov 23-Nov-12 18:18pm    
Not a valid question. What's "how"?
--SA

I would start with the first row (and the mathematical definition [^]).
You may use the recurrence relation (shown in the linked page) to compute their values (in a simple, rough approach, you might use a 10 x 10 array to store the numbers as computation proceedes).
 
Share this answer
 
v2
This is a little simpler and more flexible implementation:

C#
public static void EeulerBernoulli(int limit)
{
    var E = new List<int[]>();

    for (int n = 0; n < limit; n++)
    {
        E.Add(new int[n + 1]);
        for (int k = 0; k <= n; k++)
        {
            E[n][k] = (k != 0) ? (E[n][k - 1] + E[n - 1][n - k]) : 
                (n == 0 ? 1 : 0);
        }
    }
}
 
Share this answer
 
Just use an query like this

select TOP 10 from tablename
 
Share this answer
 
C#
static void CreatEeulerBernoulli()
{
   euler_Bernoulli[0, 0] = 1;
   for (int i = 1; i < 10; i++)
   {
      if (i % 2 == 0)
         evenArray(i);
      else
         oddArray(i);
   }
   WriteToScreen(euler_Bernoulli);
}

static void oddArray(int currentIndex)
{
   for (int i = 0; i < currentIndex; i++)
   {
      int currentSum = 0;
      for (int j = 0; j < currentIndex - i; j++)
         currentSum = euler_Bernoulli[currentIndex - 1, j] + currentSum;
         
      if (currentIndex >= i)
         euler_Bernoulli[currentIndex, currentIndex - i] = currentSum;
   }
}

static void evenArray(int currentIndex)
{
   for (int i = 0; i < currentIndex; i++)
   {
      int currentSum = 0;
      for (int j = i; j < 10; j++)
         currentSum = euler_Bernoulli[currentIndex - 1, j] + currentSum;
      
      if (currentIndex >= i)
         euler_Bernoulli[currentIndex,  i] = currentSum;
   }
}

static void WriteToScreen(int[,] result)
{
   for (int i = 0; i < 10; i++)
   {
      Console.WriteLine("array index of " + i.ToString());
      for(int k=0; k<10; k++)
         Console.Write((result[i,k].ToString())+",");
   }
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900