Algorithm help

Reply

Join Date: Mar 2008
Posts: 11
Reputation: mzdiva041986 is an unknown quantity at this point 
Solved Threads: 0
mzdiva041986 mzdiva041986 is offline Offline
Newbie Poster

Algorithm help

 
0
  #1
Sep 14th, 2008
Help me improve this algorithm please, as of now it is calulating the rows of Pascal's Triangle but I need it to calculate the colums and stop at (3,1).

for n:= 0 to k do
for m:= 0 to n do
if m=0 or m=n then A[n,m]:= 1
else
A[n,m]:=A[n-1,m-1] + A[n-1,m]
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 1,979
Reputation: Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of 
Solved Threads: 220
Featured Poster
Duoas's Avatar
Duoas Duoas is offline Offline
Posting Virtuoso

Re: Algorithm help

 
0
  #2
Sep 14th, 2008
What exactly do you mean by "columns"? The same as in your code?

If so, perhaps it would help to stare at the cute animation over at Wikipedia: Pascal's Triangle.

You'll notice that you don't have to complete a whole row to skirt down just one "column".

Good luck!
Last edited by Duoas; Sep 14th, 2008 at 8:42 am.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Pascal and Delphi Forum


Views: 946 | Replies: 1
Thread Tools Search this Thread



Tag cloud for Pascal and Delphi
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC