[Issue 7646] bug in code sample and unittest
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Sun Mar  4 12:08:33 PST 2012
    
    
  
http://d.puremagic.com/issues/show_bug.cgi?id=7646
--- Comment #1 from josvanuden at gmail.com 2012-03-04 12:08:27 PST ---
(In reply to comment #0)
> I think the code should be (n <= 2):
> 
>     ulong fib(ulong n) { 
>         alias memoize!fib mfib; 
>         return n <= 2 ? 1 : mfib(n - 2) + mfib(n - 1); 
>     }
> 
>     assert(fib(10) == 55); 
No, that still won't do. This is better:
    ulong fib(ulong n) { 
        alias memoize!fib mfib; 
        return n <= 2 ? n != 0 : mfib(n - 2) + mfib(n - 1); 
    }
-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
    
    
More information about the Digitalmars-d-bugs
mailing list