Thread: calculating binomial coefficient by simulation of pascals triangle

  1. #1
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385

    calculating binomial coefficient by simulation of pascals triangle

    This is a little problem i set myself, to create a program that dynamically generates Pascals triangle to resolve the binary co-efficient of an index. Unfortunantly ive fallen pretty early on. I cant figure a way to to add the values without creating massive arrays containg hundreds of variables or hard coding the data.

    Anybody at all have a suggestion about how i could do it.

    i get the value index form the user
    the line id of the triangle will be the same as index
    the number of variables in the line will be index +1
    and this is where i got stuck...
    Monday - what a way to spend a seventh of your life

  2. #2
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    You can use a formula to calculate the k-th number on the n-th line.

    (n k) = n! / (k! * (n - k)!)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pascal's triangle
    By Priyank in forum C Programming
    Replies: 9
    Last Post: 01-14-2011, 10:25 AM
  2. Binomial coefficient - a lamer's question
    By balazsbotond in forum C++ Programming
    Replies: 9
    Last Post: 03-26-2007, 03:25 PM
  3. Pascal's triangle algorithm
    By Zewu in forum C++ Programming
    Replies: 10
    Last Post: 06-17-2002, 12:59 PM