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

Page 1 of 1

## 1 Replies - 504 Views - Last Post: 15 March 2013 - 03:27 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=315556&amp;s=c3faafa13ed90258399cc1d5c66c1a1a&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Sam_E

Reputation: 0
• 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?

Is This A Good Question/Topic? 0

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

### #2 GregBrannon

• D.I.C Lover

Reputation: 2250
• Posts: 5,340
• 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?