On Thu, 2014-02-06 at 18:06 -0500, Dave Angel wrote:
[…]
> 
> Code:
> def fib2(n):
>       if n==1:
>               return 1
> 
>       elif n==2:
>               return 1
>       else:
>               return fib2(n-2) +fib2(n-1)
[…]

I suggest it also be pointed out that this form is algorithmically
dreadful. Having transformed the maths to this first cut code, we then
need to consider it as code and shift to a tail recursive form,
iterative form, or at the very least memoize the function. Leaving
students of programming (in any current language) with the idea that
this is a good final solution is, I believe, a disservice. 

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.win...@ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: rus...@winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to