1 Replies - 327 Views - Last Post: 15 March 2013 - 03:27 PM Rate Topic: -----

#1 Sam_E  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 08-March 13

Non-recursive algorithm for position of elements in Pascal's Trian

Posted 15 March 2013 - 03:25 PM

So I have the following recursive algorithm to calculate element of the Pascal's Triangle given the row and the column by the user:
for example, row 6, column 4 is 10


1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1

private static int Recursion(int row,int column){
        if((row == column)||(row ==0)||(column==1)){
         return 1;         
        }
        else{
        return (Recursion(row-1,column-1)+Recursion(row-1,column));
        }     
    }   



But I was asked to do it without recursion
how can I make this into a for loop?

Thanks in advance

Is This A Good Question/Topic? 0
  • +

Replies To: Non-recursive algorithm for position of elements in Pascal's Trian

#2 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2205
  • View blog
  • Posts: 5,239
  • Joined: 10-September 10

Re: Non-recursive algorithm for position of elements in Pascal's Trian

Posted 15 March 2013 - 03:27 PM

So you found something on the Internet that almost works, and you want us to help you fix it?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1