Thanks -- this one makes sense.  (It is shuffles the multiplications into a 
balanced tree so that the top-level multiplication is the product of all 
the odds (<=n) times the product of the evens.)

Sympy itself uses prime swing.

On Friday, May 16, 2014 9:50:57 AM UTC-7, Richard Fateman wrote:
>
> You are right!  So sorry!  I copied the wrong program into my note.
>
> Here is a correct version.   (Again, Peter's article is fun to read...)
>
>  (defun ff(n m) (if (<= n m) n (*(ff n (+ m m))(ff (- n m) (+ m m)))))
>
> For this one,  (ff 10 1) computes 10! and 
> does the following multiplications.
>
>  (ff 10 1)
>
> (* 10 2)
>  (* 20 6)
>  (* 8 4)
>  (* 120 32)
>  (* 9 1)
>  (* 9 5)
>  (* 7 3)
> (* 45 21)
>  (* 3840 945)
>
> 3628800
>
> The effect is far more pronounced for 100!.  There are other fun hacks 
> though.
> I hope you have the time and interest to try this on python.
> RJF
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/ab4d192c-3be7-4a3e-9358-7e8c6e6cf0f8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to