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
-~----------~----~----~----~------~----~------~--~---