Curses! And recurses! I meant "recursive" not "iterative."
Jim > Hi Scott, > > Google math is great. It will even evaluate factorials up to about 170. 170! > = 7.257416e+306 > > Most calculators show an overflow beyond 60! > > But Wolfram alpha will evaluate 300! = > 3.0605751221644063603537046129726862938858880417 × 10^614 > > And God knows how much further. > > Live code doesn't have a factorial function. > > I wrote one that works up to 170! It uses the traditional iterative method > below 60! and the Sterling approx beyond that. Beyond 170! LC shows an > overflow: > > > function fact n > if n < 60 then > return factorial (n) > else > put exp(1) into e > return ((n/e)^n) * (sqrt(2*pi*n)) --This is the Sterling approx. > end if > end fact > > function Factorial n > if n = 1 then > return 1 > else > return n * factorial(n-1) > end if > end factorial > > > >> >> Message: 21 >> Date: Tue, 09 Jul 2013 23:47:19 -0700 >> From: Scott Rossi <sc...@tactilemedia.com> >> To: LiveCode Mail List <use-livecode@lists.runrev.com> >> Subject: [OT] Google Math Fun >> Message-ID: <ce025187.222ba%sc...@tactilemedia.com> >> Content-Type: text/plain; charset="US-ASCII" >> >> When working in LiveCode, I often use the message box to do quick >> operations and avoid switching out to another application, say a math >> problem for example. Tonight I needed to do some quick operations while >> searching the Web and I had just a feeling in my gut that Google had taken >> care of this. This might be old news to some, but sure enough, I typed >> "1136 divided by 2" into the browser search field, and Google returned a >> javascript calculator pre-filled with the answer. >> >> Nice one, Google. >> >> (I now expect the day will come when Google will return a page containing >> a picture of a large camera lens and will speak to me in a synthesized >> voice: "I'm sorry, Scott. I'm afraid I can't do that.") >> >> Regards, >> >> Scott Rossi >> Creative Director >> Tactile Media, UX/UI Design >> > _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode