ScratchData LogoScratchData
Back to lemonpretzel's profile

factorial approximation v2

LElemonpretzel•Created February 7, 2013
factorial approximation v2
10
9
473 views
View on Scratch

Instructions

Turbo mode isn't necessary; this still calculates factorials really fast! A factorial of a number n, denoted by n! is n*(n-1)*(n-2)...*2*1. For example, 5! = 5*4*3*2*1=120. This is a very slow way of computing large factorials such as 100!, so I'm using a formula called Stirling's Series. Try using decimals, too! Although that's not a factorial since it's not for integers, it's like the Gamma function.

Description

UPDATE 5/23/13: It can now calculate ANY factorial (actually, up to 2.556e+305! until it says infinity). I did this by calculating log(n!) by finding the log of each component which is multiplied together, and adding them because log(a*b)=log(a)+log(b). Then, I created my own "scientific notation" by doing x=10^(log(x)-floor(log(x))) * 10^floor(log(x)). It also loops so you can easily find the factorials of different numbers. Version 2 of my factorial calculator; it now approximates factorials using Stirling's Series, which is much more accurate than my previous calculator. Stirling's Series is an infinite series, and Stirling's Approximation is merely an approximation of it. This program uses the first 17 terms of Stirling's Series to get a really precise value. http://mathworld.wolfram.com/StirlingsSeries.html It can compute up to 169 factorial!

Project Details

Project ID10038886
CreatedFebruary 7, 2013
Last ModifiedDecember 8, 2013
SharedFebruary 7, 2013
Visibilityvisible
CommentsAllowed