Results 1 to 38 of 38

Thread: Factorial of 1000000

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    WGTN, New Zealand
    Posts
    338

    Factorial of 1000000

    It took Mathematica 29 seconds to find out this HUGE number... I saved it as raw text and it's 5.5MB, so that's a number about 10^570000000 digits long isn't it? I zipped it up and was going to post it but it only compressed to around 2.5MB which is still too large.

  2. #2
    Hyperactive Member DavidHooper's Avatar
    Join Date
    Apr 2001
    Posts
    357
    Hehe, well post it up on some webspace somewhere.

    Let me see, I bet it ends in a minimum of 21 0s. Can't think of anything else I know about it tho

    Anyone?
    There are 10 types of people in the world - those that understand binary, and those that don't.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    WGTN, New Zealand
    Posts
    338
    It ends with a heap more than 21 zeros... try about 21,000 zeros...

  4. #4
    Fanatic Member siyan's Avatar
    Join Date
    Jul 2001
    Location
    GOOOAAAAALLLLL!!!!!
    Posts
    869
    It took Mathematica about ten minutes to figure PI to the millionth digit (but it was on a Celeron 550...)

    btw the millionth digit is 5

    -C

  5. #5
    Addicted Member
    Join Date
    Aug 2002
    Location
    Windsor, Ontario's City of Pollution
    Posts
    165
    siyan,

    I do not know how I could have lived up until this moment without knowing the fascinating fact that the millionth digit of pi is 5.
    Merry Math Making!

  6. #6
    Fanatic Member bugzpodder's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    787
    check out this guy's pi pages, apparently he'll tell you how to compute the 100 billionth digit of pi in under 10 minutes. http://www.cecm.sfu.ca/~pborwein/

    and i heard of a method which lets you compute nth digit of pi without computing other digits but i can't seem to find it.
    Massey RuleZ! ^-^__Cheers!__^-^ Massey RuleZ!


    Did you know that...
    The probability that a random rational number has an even denominator is 1/3 (Salamin and Gosper 1972)? This result is independently verified by me (2002)!

  7. #7
    Addicted Member
    Join Date
    Aug 2002
    Location
    London UK
    Posts
    255

    There are 241998 zeros on the end of 1000000!

    How many zeros on the end of x! depends on how many 5s you can stuff into it. As an example, 100! has 24 zeros on the end, because in 1 x 2 x 3 x ... x 99 x 100, you have multiples of 5 (there are 20), and also 25 can be expressed as 5 x 5, and likewise so can multiples of that (of which there are 4). So that's 24. The reason this all works is that there are god knows how many more 2s than 5s, and each 5 can pair off with a 2 to make a 10, adding a zero onto the end.

    On the end of 1000000! there should be:

    200000 multiples of 5, 40000 multiples of 5 x 5, 1600 multiples of 5 x 5 x 5, 320 multiples of 54, 64 multiples of 56, 12 multiples of 57, and finally 2 multiples of 58 which makes 241998 zeros on the end of 1000000!

    Hey Bugz dude, is that right? Can you count them for me?
    Not at all related to sheep...

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    WGTN, New Zealand
    Posts
    338
    That looks about right, after saving just the zeros into another file... it was around 250kb or something.

    I heard somewhere, that even if every atom could represent a number, there would not be enough of them to store all the prime numbers up to 10500. In fact if you think about it you can't get very near that number at all.

  9. #9
    PowerPoster Evil_Giraffe's Avatar
    Join Date
    Aug 2002
    Location
    Suffolk, UK
    Posts
    2,555
    Represent it as a product of primes shouldn't be so bad. Especially if you got a computer on the case.
    For each integer from 1 to 1000000 work out its product of prime representation then keep a count of how many times each prime comes up. Should be a bit smaller than just writing it out. That should also give you a fairly good way to work out how many zeroes are at the end.

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    WGTN, New Zealand
    Posts
    338
    Someone else can do that... I'm not very good at maths nor am I very good at Mathematica.

  11. #11
    Addicted Member
    Join Date
    Jul 2002
    Location
    Ontario Canada
    Posts
    236
    What's Mathematica?
    YL says:"Few are those who see with their own eyes and feel with their own hearts."(Einstein)

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    WGTN, New Zealand
    Posts
    338
    Edited parts in BOLD

    It's a computer program which can do a lot of mathematical stuff, ie Factorial of 1,000,000. It uses it's own kernel to do the math (so obviously it will take longer), but it can calculate almost anything you give it provided it's solve-able and to do with maths. It's more advanced than I've described it here, muuuuuch more advanced. More information below.

    Unfortunately it's not free and my version is pirated. It costs a large sum, and I think it's from http://www.wolfram.com/.

    Happy hunting.
    Last edited by Dreamlax; Sep 9th, 2002 at 06:12 AM.

  13. #13
    Addicted Member
    Join Date
    Jul 2002
    Location
    Ontario Canada
    Posts
    236
    Yeah i think i have that too. I'm not sure how it works though lol.
    Last edited by SilverSprite; Sep 9th, 2002 at 06:24 AM.
    YL says:"Few are those who see with their own eyes and feel with their own hearts."(Einstein)

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    WGTN, New Zealand
    Posts
    338
    Just type in 5+8 and press Shift+Enter and if it's configured right it will take 2 seconds to 'warm up' the kernel and then return 13. After that the calculations take less time since the kernel is in memory (already loaded).

  15. #15
    Addicted Member
    Join Date
    Jul 2002
    Location
    Ontario Canada
    Posts
    236
    wow that works! anyway i have version 4.2. How do factorials or pi?
    YL says:"Few are those who see with their own eyes and feel with their own hearts."(Einstein)

  16. #16
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    I've only got version 4.0 here
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  17. #17
    Addicted Member
    Join Date
    Jul 2002
    Location
    Ontario Canada
    Posts
    236
    How would you do factorials, pi, or exponential notation using mathematica?
    YL says:"Few are those who see with their own eyes and feel with their own hearts."(Einstein)

  18. #18

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    WGTN, New Zealand
    Posts
    338
    Code:
    Factorial[100] shift enter
    
    N[Pi, 100] shift enter
    The first one calculates the factorial of 100, the second calculates Pi to 100 d.p.

  19. #19
    Fanatic Member sql_lall's Avatar
    Join Date
    Jul 2002
    Location
    Up Above (i.e. AUS)
    Posts
    571

    ANYWAY...

    Yes, that is how you work out how many Terminal zeros there are. (Just count up factors of fives as you did) However, the more challenging Question is, what is the right-most non zero digit???? There is a quick way of finding it, i just have to find the book its in.
    sql_lall

  20. #20
    Addicted Member
    Join Date
    Jul 2002
    Location
    Ontario Canada
    Posts
    236
    how come i cant take the factorial of a large number? And the pi thing is real cool!
    YL says:"Few are those who see with their own eyes and feel with their own hearts."(Einstein)

  21. #21
    Fanatic Member bugzpodder's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    787
    right most non-zero digit? easy.

    of course you need to use a program to do it.

    loop from 1 to N {i}
    lets say 'i' is divisible by 2^a, where a is the largest integer such that 2^a<i
    and 'i' is divisible by 5^b, where b is the largest integer such that 5^b<i
    k=(k*i/(2^a*5^b)) mod 10
    numberOfTwo+=a
    numberOfFive+=b
    }

    loop from 1 to numberOfTwo-numberOfFive
    k=(k*2)mod 10

    and k would be the right-most non-zero digit
    Last edited by bugzpodder; Sep 13th, 2002 at 03:48 PM.
    Massey RuleZ! ^-^__Cheers!__^-^ Massey RuleZ!


    Did you know that...
    The probability that a random rational number has an even denominator is 1/3 (Salamin and Gosper 1972)? This result is independently verified by me (2002)!

  22. #22
    Fanatic Member bugzpodder's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    787
    another way is to count up the prime factors of every number from 1 to N, and keep it in an array. just set the number of twos to number of twos - number of fives and set number of fives to 0 and then multiply them all together (do mod 10 every time) and u get ur digit
    Massey RuleZ! ^-^__Cheers!__^-^ Massey RuleZ!


    Did you know that...
    The probability that a random rational number has an even denominator is 1/3 (Salamin and Gosper 1972)? This result is independently verified by me (2002)!

  23. #23

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    WGTN, New Zealand
    Posts
    338
    Originally posted by SilverSprite
    how come i cant take the factorial of a large number? And the pi thing is real cool!
    Give it some time. Factorial of 1,000,000 took 29 seconds on an overclocked dual 1,400MHz (not that the dual makes any difference [Mathematica only uses one CPU], just sounds better) with 1.5GB DDR memory. It's like this because my brother and I use it to benchmark stuff, and or course doing large calculations, or brute forcing ZIP files etc etc.

    In order to use e (2.71828) you have to use a capital E. For i (i2=-1) you have to use a capital I. Basically any constant or function begins with a capital (E, I, Pi, Log, Solve, Factor, Expand etc.)


    On another note:
    Has anyone coded that new formula for finding primes which is apparently the most efficient way yet?

  24. #24
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Originally posted by Dreamlax

    Has anyone coded that new formula for finding primes which is apparently the most efficient way yet?
    which ?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  25. #25

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    WGTN, New Zealand
    Posts
    338
    http://zdnet.com.com/2100-1104-949170.html

    http://www.cse.iitk.ac.in/news/primality.pdf

    First one is just a news article about the new prime number thing, the second is the actual algorithm.

  26. #26
    Addicted Member
    Join Date
    Jul 2002
    Location
    Ontario Canada
    Posts
    236
    No dreamlax. When i input Factorial[100000000]or something big like that, i just get 100000000! as output. It doesnt say running as it should. When i factorial smaller numbers it works fine.
    YL says:"Few are those who see with their own eyes and feel with their own hearts."(Einstein)

  27. #27

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    WGTN, New Zealand
    Posts
    338
    Woah woah! Even Mathematica has a limit! Just because it can do stuff Windows Calculator can't do doesn't mean it can do the factorial of 100,000,000 ! That number would be excessively huge and would probably need A LOT of RAM and CPU power... not to mention time.

  28. #28
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Not necessarily.
    If you think about it, you start at half the number itself.
    Then a third of the number.
    Then a quarter of the number.

    Those should be the whole number factors of the number in order.
    And basically once you've gone far enough with those, then just get the factors of those smaller numbers.

    You could in fact store them in a DB for handiness
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  29. #29
    PowerPoster Evil_Giraffe's Avatar
    Join Date
    Aug 2002
    Location
    Suffolk, UK
    Posts
    2,555
    Factorial, not Factor.
    As in n! = 1*2*3*...*(n-1)*n
    Theoretically, it shouldn't need to have an upper limit. I wrote a class in VB in a couple of hours that could extend to any integer. When it got beyond the range, it just added another byte to itself and continued. Got the basic mathematical operations - add, subtract, multiply, divide, divide by a power of two (optimised to be a bit shift ), exponential. It was all written to take advantage of modulus arithmetic, so it would have needed rewriting for general use. It wasn't hugely quick either, I was trying to raise a number (approx 20 hex digits) to a power (approx 40 hex digits) modulus another number (approx 30 hex digits) and it took about a day and a half. Of course, I did forget I could reduce the exponent first :$

  30. #30

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    WGTN, New Zealand
    Posts
    338
    I remember I attempted to do something similar to that, but then again let your kernel do 100,000,000 factorial! It will take a while and eat a LOT of RAM I bet!

  31. #31
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Duh sorry yeah I read factors, not factorial

    Anyway, Evil_Giraffe, you're talking about PowerMod.
    That's required in RSA cryptography, and there are well known methods of simplifying the expression
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  32. #32
    PowerPoster Evil_Giraffe's Avatar
    Join Date
    Aug 2002
    Location
    Suffolk, UK
    Posts
    2,555
    No, it was one I wrote myself. The place where I do my summer work had lost the admin password to one of their systems, but managed to find an encrypted password and a "server key" in the Windows registry. So the first task they set me on was trying to crack it. But it turns out that it wasn't just a straight RSA encrypted password. When I'd spent a week finely crafting a decryption program (read: coding one big huge dirty hack) and come out with a password that contained over 50% of the non-keyboard characters they tried ringing the company that produced to get a password reset script.

  33. #33
    Fanatic Member sql_lall's Avatar
    Join Date
    Jul 2002
    Location
    Up Above (i.e. AUS)
    Posts
    571

    Question Hmm...

    bugz, how does that loop work??

    neway, if you are using programming, wouldn't it be easier to do this:
    [Highlight=VB]
    dim lastdigit
    For a = 1 to 10000000 'whatever number
    lastdigit = lastdigit * a
    do while lastdigit mod 10 = 0
    lastdigit = lastdigit/10
    loop
    next a
    sql_lall

  34. #34
    Fanatic Member bugzpodder's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    787
    i don't think so sql_lall

    5*20=100
    25*20=500

    if u chop off the digits soon enough, you'll get 100 as an answer
    otherwise you get 500. well you get the idea


    plz state the part you don't understand about the loop.
    Massey RuleZ! ^-^__Cheers!__^-^ Massey RuleZ!


    Did you know that...
    The probability that a random rational number has an even denominator is 1/3 (Salamin and Gosper 1972)? This result is independently verified by me (2002)!

  35. #35
    PowerPoster Evil_Giraffe's Avatar
    Join Date
    Aug 2002
    Location
    Suffolk, UK
    Posts
    2,555
    Originally posted by bugzpodder
    right most non-zero digit? easy.

    of course you need to use a program to do it.

    loop from 1 to N {i}
    lets say 'i' is divisible by 2^a, where a is the largest integer such that 2^a<i
    and 'i' is divisible by 2^b, where b is the largest integer such that 2^b<i
    k=(k*i/(2^a*5^b)) mod 10
    numberOfTwo+=a
    numberOfFive+=b
    }

    loop from 1 to numberOfTwo-numberOfFive
    k=(k*2)mod 10

    and k would be the right-most non-zero digit
    if you wrote ...and 'i' is divisible by 5^b, where b is the largest integer s.t. 5^b<i there may be less confusion

  36. #36
    Addicted Member
    Join Date
    Aug 2002
    Location
    Windsor, Ontario's City of Pollution
    Posts
    165
    On the note of pi, a professor informed me that the distribution of the digits of pi are so close to being 10% for each digit, 1% for each pair of two digits, etc, that it suspiciously resembles a random set of digits. Despite the fact that there is mathematical formula for generating pi, it's digits appear to come from a random number generator!!!
    Merry Math Making!

  37. #37
    Fanatic Member bugzpodder's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    787
    Originally posted by Evil_Giraffe
    if you wrote ...and 'i' is divisible by 5^b, where b is the largest integer s.t. 5^b<i there may be less confusion
    thx i've fixed it now silly old me
    Massey RuleZ! ^-^__Cheers!__^-^ Massey RuleZ!


    Did you know that...
    The probability that a random rational number has an even denominator is 1/3 (Salamin and Gosper 1972)? This result is independently verified by me (2002)!

  38. #38
    Addicted Member
    Join Date
    Jul 2002
    Location
    Ontario Canada
    Posts
    236
    Nobody care for kalkewl8ter! lol
    YL says:"Few are those who see with their own eyes and feel with their own hearts."(Einstein)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width