comp.lang.ada
 help / color / mirror / Atom feed
From: Mehdi Saada <00120260a@gmail.com>
Subject: Re: Pascal triangle algorithm ("homework"). iterative one. the direct one was simple.
Date: Sat, 30 Jan 2021 08:55:06 -0800 (PST)	[thread overview]
Message-ID: <ed1e1775-e707-4d10-9573-69c6d2524d17n@googlegroups.com> (raw)
In-Reply-To: <60158b04$0$19449$426a34cc@news.free.fr>

> To get an answer, you have to describe your problem. 
> Posting code and console output is not enough.
Sorry. well it should output the n_rank'th (here 6th, but in general as given in the argument) row of Pascal's triangle, through iterating over each row until the required one.
there are two loops.
first one, the main one, change rows after filling them at each iteration, then swap temp1( n-1 row) and temp2 (nth row).
then the second ,inner loop, where apparently the problem is. Here it loops over a single row, by filling each element of the nth row one at a time by adding the nth and (n-1)th element of the preceding row. It does compute it for the first second first loop iteration as shown by the verification (temp2(i) = temp1(i-1) + temp1(i) = 2)
but from there, since the swap routine works, I don't understand why it does not carry one.
temp2 :
1
2
why from there can't it continue, with temp2(3) := temp1(2) + temp1(3) [ =  1 + 0
... well now I don't remember whether or not I put a 0 at the end of each row. But If I didn't it should crash ?
Unless N should be incremented an the loop continues one further...
I'll test that... once GNAT works again, as it crashes twice... two different versions, as explained elsewhere. Not my fault, for once.

I hope I explained better.

  reply	other threads:[~2021-01-30 16:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-30 14:40 Pascal triangle algorithm ("homework"). iterative one. the direct one was simple Mehdi Saada
2021-01-30 16:36 ` DrPi
2021-01-30 16:55   ` Mehdi Saada [this message]
2021-01-30 23:42     ` Mehdi Saada
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox