none
how to find the factorial of a big number

    Question

  • Dear all,

    This question is of dealing with large values of integers.

     I would like to know the logic of how to fine the factorial of a very big number, lets say factorial of 100.

    Thanks and regards,

    Raja Pratap.

    Monday, May 08, 2006 9:25 AM

Answers

  • There is no solution in Visual Studio for this.  Search the web for "bignum library" for libraries and source code you might use.

    e.g. GMP looks good, but I don't see any references to VS-compliation.  http://www.swox.com/gmp/ is a web interface so you can experiment: try 100!

    Brian

     

    Monday, May 08, 2006 1:04 PM

All replies

  • There is no solution in Visual Studio for this.  Search the web for "bignum library" for libraries and source code you might use.

    e.g. GMP looks good, but I don't see any references to VS-compliation.  http://www.swox.com/gmp/ is a web interface so you can experiment: try 100!

    Brian

     

    Monday, May 08, 2006 1:04 PM
  • Dear all,

    This question is of dealing with large values of integers.

     I would like to know the logic of how to fine the factorial of a very big number, lets say factorial of 100.

    Thanks and regards,

    Raja Pratap.

    Hi Raja Pratap,

    Please see this example which shows the result of the factorial of 500.>>

    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/bb23b85f-9a88-4dae-a54e-df71cd25b59d/

    Sorry the code in the post is in Vb.Net but you could put the functions into a DLL ( class library project ) and

    use them in Visual C++ that way, or convert the code to Visual C++.

    I've added the link here in case any of you find it useful.   :-)   ;-)

    See also this thread if you wish.>>

    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/4ec2bc19-b35d-4e27-9790-2bdf4b5ff153

     


    Regards, John : Trying hard for another goal into the .Net!!
    Wednesday, June 23, 2010 6:07 PM
  • >Hi Raja Pratap ...

    John -

    Did you just reply to a message that was posted
    more than four years ago?

    - Wayne
    Thursday, June 24, 2010 12:06 AM
  • John -

    Did you just reply to a message that was posted
    more than four years ago?

    - Wayne

    Hi Wayne,

    Yes I did and why not?

    If it also helps other forum members too, then why not?  :-)

     

    I don't just think of the Original Poster you know.   :-D

     

    Often related threads appear on the right-hand-side of the forum website pages, have you noticed?


    Regards, John : Trying hard for another goal into the .Net!!
    Thursday, June 24, 2010 5:41 PM
  • Hi;

    You need a Big integer library to do this..

    the only way to do it  without 3rd party libraries is using scientifc mode. (100! = 9.33262e+157)

    Thursday, June 24, 2010 11:15 PM
  • >Yes I did and why not?

    No reason not to, as long as you *realize* that you're
    posting to an ancient thread and that the original
    poster - *to whom you addressed your reply * - may
    have moved on and the issue may have lost some of
    its original urgency after four years.

    - Wayne
    Friday, June 25, 2010 2:57 AM
  • >Yes I did and why not?

    No reason not to, as long as you *realize* that you're
    posting to an ancient thread and that the original
    poster - *to whom you addressed your reply * - may
    have moved on and the issue may have lost some of
    its original urgency after four years.

    - Wayne

    Hi Wayne,

    Yes of course I realised the original poster may have moved on. :-)

    I also add posts for the benefit of other forum users who may

    actually use the forum search box at the top of the forums. ;-)


    Regards, John : Trying hard for another goal into the .Net!!
    Friday, June 25, 2010 3:24 AM
  • Hi;

    You need a Big integer library to do this..

    the only way to do it  without 3rd party libraries is using scientifc mode. (100! = 9.33262e+157)

    Hi Xpero,

    No you don't.

    100! =

    9332621544394415268169923885626670049071596826438162146859296389521759999

    3229915608941463976156518286253697920827223758251185210916864000000000000000000000000

     

    Read the above two lines as one long number for the answer. ;-)

     

    Calculated with the .Net code from here.>>

    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/bb23b85f-9a88-4dae-a54e-df71cd25b59d/

     

    It works out the answer using a long string.    :-)    :-D

     

    Windows calculator gives this result in case you want to check the first 32 digits.>>

    9.3326215443944152681699238856267e+157



    Regards, John : Trying hard for another goal into the .Net!!
    Friday, June 25, 2010 3:32 AM
  • (Sorry, I mistook to use "Propose As Answer" button on the article above.)

    For your information:

    I made a Small Basic program to calculate factorial of big number.

    Published as HHW468.

    Following list is a sample of 1000!.  It took about 4 minutes.

    1000!=40238726007709377364012323402258624240614242652116076141147840447006450218
    07068877845325723866297088875413637239043830555816450278524776776482904332510705
    17379104539615568859272541626540731379637708602500485434758632539955740412098144
    87641219746390044297213105673537158369902906405487142364448279919170212481721041
    75873219659175968066116731989363191605033629663935193037563103540530764576421849
    23878437519832364772318965936404776496659074605344310417725655414253545981447314
    64958042095832208237066282250232394045857267591454546343254034164367035723472247
    56212598313227906133015754429984273284536281846149197857856617471449042804873986
    58045778502953860877994143246744372491095597634023889537528234836724306048954914
    97891690891722262128054846506203153341713482198041743812377049351225041047282427
    56408624991682725475881754098077044450340573327812283591389497447640520252458008
    84915016535208770722442645575776351813865029031472635140500248875847109069890236
    62913040964683012884108373998973671333269626257394668499627164966772416719188098
    39419025308052134204270853401815289907730166739332086215953255675695171871154744
    34100805272599095786799563484968606298542535119971678341269898487203269134736808
    80276472043126093090537280813187385808294638432622085731484346948707091559016845
    44332716611958775580499374533274723463059673025081211374918343644924102771429127
    97165167668460362333631501791836537580993766744473049886568690104547431817838821
    72033773925260841650574014429576747363529323304721958635120802958545244761790108
    16948115362294873043103589123221684076712141111832987977035701792534068205615293
    96653917242927877181504980087455145358194244608488750370593404486231412929521624
    92776468618444001054189126288932813224318299484872808539834984136341239260576035
    07243646167237601189977852697109117561932733795512791979898805118214161624462099
    45353136135826060658691498553405388189248327204078235475141234752058068189558057
    99327987084618453059656621300071000853566570559178621995008774257487908571109850
    99042089585035012512358748310094037121872798618627660636916167926127252004240593
    56508526592654655603187707799788938563404444728943997135206735017412389500701434
    81079751381941793573492618567679666933042247588628130041513093809380742967789525
    13223871624506127100798702761593308399135477500991765121077249245459394109700277
    53472000000000000000000000000000000000000000000000000000000000000000000000000000
    00000000000000000000000000000000000000000000000000000000000000000000000000000000
    00000000000000000000000000000000000000000000000000000000000000000000000000000000
    00000000000000
    (220119ms)


    Nonki Takahashi


    P.S. This algorithm may have bugs.  I'll continue to follow this algorithm in other thread "Calculate with Big Numbers in Small Basic".
    Sunday, April 22, 2012 4:50 AM