VB 2010 - Need help-VBForums
Results 1 to 7 of 7

Thread: VB 2010 - Need help

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2011
    Posts
    11

    Question VB 2010 - Need help

    I need to create an application that creates Pascal's triangle
    the user would enter the number of rows, and using the formula (which i do not know... :/) would create the triangle. For example: the user enters 5 rows
    triangle:
    1
    1 1
    1 2 1
    1 3 3 1
    1 4 6 4 1
    as you can see the numbers are created by adding the 2 numbers above it starting with 1 at the top

  2. #2
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,779

    Re: VB 2010 - Need help

    In order to make an application, you need to understand the logic of it. I guess you need to go and find out what the formula is first.

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2011
    Posts
    11

    Re: VB 2010 - Need help

    you learn it in grade 11 math, which i have next semester...

  4. #4
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,291

    Re: VB 2010 - Need help

    If you searched this forum for "pascal's triangle", you would've have found this thread:

    http://www.vbforums.com/showthread.php?t=655198

    I wrote some functions to generate the Pascal's triangle not too long ago, and when I saw your question, I knew immediately it has been solved before
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2011
    Posts
    11

    Re: VB 2010 - Need help

    thanks man (y)

  6. #6
    Junior Member
    Join Date
    Oct 2011
    Posts
    20

    Re: VB 2010 - Need help

    At the tip of Pascal's Triangle is the number 1, which makes up the zeroth row. The first row (1 & 1) contains two 1's, both formed by adding the two numbers above them to the left and the right, in this case 1 and 0 (all numbers outside the Triangle are 0's). Do the same to create the 2nd row: 0+1=1; 1+1=2; 1+0=1. And the third: 0+1=1; 1+2=3; 2+1=3; 1+0=1. In this way, the rows of the triangle go on infinitly. A number in the triangle can also be found by nCr (n Choose r) where n is the number of the row and r is the element in that row. For example, in row 3, 1 is the zeroth element, 3 is element number 1, the next three is the 2nd element, and the last 1 is the 3rd element. The formula for nCr is:

    n!
    --------
    r!(n-r)!
    Does this help?

  7. #7
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Re: VB 2010 - Need help

    The formula that creates the triangle is 11 ^ (row number - 1)... isn't it? With a BigInteger you could calculate any row.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.