[Tutor] finding factorials - hmm..., gcd

Payal Rathod payal-python@staticky.com
Tue Jul 1 14:58:02 2003


On Tue, Jul 01, 2003 at 11:15:01AM +0100, glingl wrote:
> Your code is ok and gives the right result!
> e.g change:  x, y = 25, 15 and you will get:

Are you sure? I mean I don't get what a common factor means? Can you
tell?

> # (1) normally it's not considered good practice to pu
> #     print-statements in a function which aims at calculating
> #     a numerical rsult. - 


Why??? I mean it is good for troubleshooting/debugging.

> # (2) here you use an uncoditional return - so the body of
> #     the while-loop will be exited after the first run. 

I don't get this. You mean to say that once I type return euclid(a,b),
the while loop stops? Why? Also, if it does not get executed how am I
getting right answers as you say?

> #     Consequently it will never work as a loop and you could
> #     (a)  use an if instead of while or

Can you point a small example in *this* context using an if statement?

> #     (b)  drop the return and recursive call of euclid - 
> #          recursion also accomplishes some sort of iteration
> #          and should/need/(must?) not be done in addition 
> #          to the while-iteration  

I didn't get your meaning on this too, please.

> # (3) here you can leave out the three statements
> #
> #               c = a
> #               a = b
> #               b = c % a
> #
> # if think carefully about which values are to be
> # inserted as arguments in the recursive function
> # call.
> # What are the values of a and b respectively after
> # execution of these 3 statements. (Remember: ist is
> # perfectly right to insert arithmetic expressions like
> # a / b, a+b etc as arguments - in which case they
> # will be computed (evaluated( before the results are 
> # "bound" to the parameters.)

Ahh! Sorry again, I didn't get you. I don't understand much programmers
jargon. The whole paragraph looks greek to me.

> P.S.: Maybe http://www.ibiblio.org/obp/thinkCSpy/ ,
> especially chapters 4 to 6,
> contains material, which could be helpful for you. 

I had read them 2 days back. Maybe I should read them again.


Thanks a lot for the time and patience.
With warm regards,
-Payal

-- 
"Visit GNU/Linux Success Stories"
http://payal.staticky.com
Guest-Book Section Updated.