From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7d341239f5ebf858 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!hwmnpeer01.lga!hwmedia!news-server.columbus.rr.com!tornado.ohiordc.rr.com.POSTED!53ab2750!not-for-mail From: "John B. Matthews" Newsgroups: comp.lang.ada Subject: Re: Big numbers References: User-Agent: MT-NewsWatcher/3.4 (PPC Mac OS X) Message-ID: Date: Mon, 18 Apr 2005 13:40:45 GMT NNTP-Posting-Host: 65.31.62.213 X-Complaints-To: abuse@rr.com X-Trace: tornado.ohiordc.rr.com 1113831645 65.31.62.213 (Mon, 18 Apr 2005 09:40:45 EDT) NNTP-Posting-Date: Mon, 18 Apr 2005 09:40:45 EDT Organization: Road Runner High Speed Online http://www.rr.com Xref: g2news1.google.com comp.lang.ada:10523 Date: 2005-04-18T13:40:45+00:00 List-Id: In article , "Doker" wrote: > program like that one can count only up to 29. what can i do to deal with > data up to 100? > function Silnia ( > Liczba : Long_Long_Integer) > return Long_Long_Integer is > Efekt : Long_Long_Integer := 1; > begin > for I in 2..Liczba loop > Efekt := Efekt * I; > end loop; > return Efekt; > end; Unless I misunderstand, Silnia returns the factorial of Liczba. Calculating Silnia(100) would require over 500 bits of storage. I must be missing something, because your program should fail for Liczba > 20. What is the size of your implementation's Long_Long_Integer? Given the following bc program, define f (x) { if (x <= 1) return (1); return (f(x-1) * x); } print "2^64: ", 2^64, "\n" for (i = 20; i < 30 ; i ++ ) { print i, "!: ", f(i), "\n" } print "100!: ", f(100), "\n" print "log2(100!): ", l(f(100)) / l(2), "\n" quit I get the following output: $ bc -ql fac.bc 2^64: 18446744073709551616 20!: 2432902008176640000 21!: 51090942171709440000 22!: 1124000727777607680000 23!: 25852016738884976640000 24!: 620448401733239439360000 25!: 15511210043330985984000000 26!: 403291461126605635584000000 27!: 10888869450418352160768000000 28!: 304888344611713860501504000000 29!: 8841761993739701954543616000000 100!: 93326215443944152681699238856266700490715968264381621468\ 59296389521759999322991560894146397615651828625369792082\ 7223758251185210916864000000000000000000000000 log2(100!): 524.76499329005968632625 -- John jmatthews at wright dot edu www dot wright dot edu/~john.matthews/