Eras, Pedro! explica o código - put some comments!  Não entendi nada, e
sou matemático.

Aparentemente fazes alguma seleção entre par e impar, mas não entendi
porque.

Tarcisio
On Wed, 2009-04-29 at 14:10 -0700, Pedro Kröger wrote:
> namekuseijin <[email protected]> writes:
> 
> > até 1000 aqui no DrScheme em um Core 2 Duo é praticamente instantâneo.
> >  20000 são cerca de 2 segundos.  Faz 100.000! em 1 minuto.  A evolução
> > das máquinas é fantástica :)
> 
> a evolução dos algoritimos tambem, o seguinte codigo demora 5.341
> segundos na minha maquina para n=100000 com sbcl ;-)
> 
> (defun ! (n)
>   (let ((shift 0))
>     (labels ((fact1 (n m)
>                (cond
>                  ((and (evenp n) (> m 1))
>                   (incf shift (ash n -1))
>                   (fact1 (ash n -1) (ash m -1)))
>                  ((<= n m) n)
>                  (t (* (fact1 n (ash m 1)) (fact1 (- n m)(ash m 1)))))))
>       (ash (fact1 n 1) shift))))
> 
> pedro
> 
> > 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lisp-br" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/lisp-br?hl=en
-~----------~----~----~----~------~----~------~--~---

Responder a