Re: computing 20! all the way
Re: computing 20! all the way
- Subject: Re: computing 20! all the way
- From: Martin Orpen <email@hidden>
- Date: Fri, 12 Nov 2004 00:29:23 +0000
Title: Re: computing 20! all the way
on 11/11/04 10:56 pm, Brian Johnson wrote:
>
> My daughter is sitting here with an assignment to calculate 20!
>
> I did the obvious:
>
> set p to 1
> repeat with i from 1 to 20
> set p to i * p
> end repeat
> p
> --> 2.43290200817664E+18
>
> but it's wanted as a whole number (no scientific notation). Any
> suggestions? Cobol? used to tolerate really big integers, iirc, but can AS
> deal with this?
If you/she uses OS X then you use bc when you want to work with *big* numbers:
set nString to {"1"}
repeat with n from 1 to 20
set end of nString to "*" & n
end repeat
set theResult to do shell script "echo " & (nString as string) & " | bc"
-->2432902008176640000
Regards
--
Martin Orpen
Idea Digital Imaging Ltd -- The Image Specialists
http://www.idea-digital.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden