Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. 1000!

1000!

Scheduled Pinned Locked Moved C#
csharphelp
23 Posts 12 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rockxuyenmandem
    wrote on last edited by
    #1

    Plz help me to solve the below excise: Write a program to calculate 1000! in C# language I tried so hard and got so far

    S A L P 4 Replies Last reply
    0
    • R rockxuyenmandem

      Plz help me to solve the below excise: Write a program to calculate 1000! in C# language I tried so hard and got so far

      S Offline
      S Offline
      spin vector
      wrote on last edited by
      #2

      You need to use Stirling's formula, which asymptotically goes as n^n e^(-n). I'd prob take the log of this as a first calculation, or do something to avoid the n^n.

      S S 2 Replies Last reply
      0
      • S spin vector

        You need to use Stirling's formula, which asymptotically goes as n^n e^(-n). I'd prob take the log of this as a first calculation, or do something to avoid the n^n.

        S Offline
        S Offline
        spin vector
        wrote on last edited by
        #3

        In fact, n^n e^(-n) = exp( n ln(n) - n ), so calculate the argument and take the exponential (natural).

        1 Reply Last reply
        0
        • R rockxuyenmandem

          Plz help me to solve the below excise: Write a program to calculate 1000! in C# language I tried so hard and got so far

          A Offline
          A Offline
          albCode
          wrote on last edited by
          #4

          int i,f; f=1; string factorial=""; for (i=1; i<=1000;i++) { f= f*i; factorial = f.ToString(); //additional /*if(i==33) { break; } */ } this.label1.Text = factorial; but u can get factorial until 33 otherwise 1000! gives u result 0 (zero) _____________________ Proud to be Albanian _____________________

          D S 2 Replies Last reply
          0
          • R rockxuyenmandem

            Plz help me to solve the below excise: Write a program to calculate 1000! in C# language I tried so hard and got so far

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            We don't do your homework. Where exactly are you stuck? Just a hint: look up the term "faculty" in google. regards

            1 Reply Last reply
            0
            • R rockxuyenmandem

              Plz help me to solve the below excise: Write a program to calculate 1000! in C# language I tried so hard and got so far

              P Offline
              P Offline
              Professor Sharada Ulhas
              wrote on last edited by
              #6

              rockxyuenmandem! when i hear of ur cheating i cried loudly. i not want my student to cheat on cpian but u have failed me u monkey turd! now i want to die

              Sincelery yours, Computer Information conSciences Professor and grader, Sharada Ulhas

              A E D S 4 Replies Last reply
              0
              • P Professor Sharada Ulhas

                rockxyuenmandem! when i hear of ur cheating i cried loudly. i not want my student to cheat on cpian but u have failed me u monkey turd! now i want to die

                Sincelery yours, Computer Information conSciences Professor and grader, Sharada Ulhas

                A Offline
                A Offline
                albCode
                wrote on last edited by
                #7

                sorry maybe i shouldnt answer, I really apologise _____________________ Proud to be Albanian _____________________

                1 Reply Last reply
                0
                • P Professor Sharada Ulhas

                  rockxyuenmandem! when i hear of ur cheating i cried loudly. i not want my student to cheat on cpian but u have failed me u monkey turd! now i want to die

                  Sincelery yours, Computer Information conSciences Professor and grader, Sharada Ulhas

                  E Offline
                  E Offline
                  eggie5
                  wrote on last edited by
                  #8

                  HAAHA are you indian? /\ |_ E X E GG

                  A 1 Reply Last reply
                  0
                  • P Professor Sharada Ulhas

                    rockxyuenmandem! when i hear of ur cheating i cried loudly. i not want my student to cheat on cpian but u have failed me u monkey turd! now i want to die

                    Sincelery yours, Computer Information conSciences Professor and grader, Sharada Ulhas

                    D Offline
                    D Offline
                    Dan Neely
                    wrote on last edited by
                    #9

                    You're still old a week after your last attack.

                    P P 2 Replies Last reply
                    0
                    • D Dan Neely

                      You're still old a week after your last attack.

                      P Offline
                      P Offline
                      Professor Sharada Ulhas
                      wrote on last edited by
                      #10

                      O Dan, thou hast shown unto me thine utmost kindness, and thine words speak in songs of beauty and elegance.

                      Sincelery yours, Computer Information conSciences Professor and grader, Sharada Ulhas

                      P 1 Reply Last reply
                      0
                      • P Professor Sharada Ulhas

                        O Dan, thou hast shown unto me thine utmost kindness, and thine words speak in songs of beauty and elegance.

                        Sincelery yours, Computer Information conSciences Professor and grader, Sharada Ulhas

                        P Offline
                        P Offline
                        prrusa
                        wrote on last edited by
                        #11

                        You would think they would catch on by now..:) Keep up the good work bagging them...

                        1 Reply Last reply
                        0
                        • D Dan Neely

                          You're still old a week after your last attack.

                          P Offline
                          P Offline
                          prrusa
                          wrote on last edited by
                          #12

                          You think his students should cheat? I feel he is being kind! I wait till the end of the semester before telling them I caught them cheating and then fail them.

                          1 Reply Last reply
                          0
                          • P Professor Sharada Ulhas

                            rockxyuenmandem! when i hear of ur cheating i cried loudly. i not want my student to cheat on cpian but u have failed me u monkey turd! now i want to die

                            Sincelery yours, Computer Information conSciences Professor and grader, Sharada Ulhas

                            S Offline
                            S Offline
                            Sean Michael Murphy
                            wrote on last edited by
                            #13

                            Professor Sharada Ulhas wrote:

                            Sincelery yours, Computer Information conSciences Professor and grader, Sharada Ulhas

                            Professor? If this is an example of an assignment at your university, you may want to put a "stop" on that tuition cheque... Share and enjoy. Sean

                            P 1 Reply Last reply
                            0
                            • A albCode

                              int i,f; f=1; string factorial=""; for (i=1; i<=1000;i++) { f= f*i; factorial = f.ToString(); //additional /*if(i==33) { break; } */ } this.label1.Text = factorial; but u can get factorial until 33 otherwise 1000! gives u result 0 (zero) _____________________ Proud to be Albanian _____________________

                              D Offline
                              D Offline
                              Dave Kreskowiak
                              wrote on last edited by
                              #14

                              Congratulations!! You just did his homework for him!! And WOW, he didn't learn a damn thing!! :laugh: RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                              1 Reply Last reply
                              0
                              • S spin vector

                                You need to use Stirling's formula, which asymptotically goes as n^n e^(-n). I'd prob take the log of this as a first calculation, or do something to avoid the n^n.

                                S Offline
                                S Offline
                                Steve Pullan
                                wrote on last edited by
                                #15

                                nyc_user wrote:

                                You need to use Stirling's formula,

                                Yes but... this is an approximation (admittedly with an error approaching 1/n^2 for n=1000) and won't be good enough if the exact value is required. ...Steve 1. quod erat demonstrandum 2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once :-) (Translation: I'll show you the way, but not write the code for you.)

                                S 1 Reply Last reply
                                0
                                • A albCode

                                  int i,f; f=1; string factorial=""; for (i=1; i<=1000;i++) { f= f*i; factorial = f.ToString(); //additional /*if(i==33) { break; } */ } this.label1.Text = factorial; but u can get factorial until 33 otherwise 1000! gives u result 0 (zero) _____________________ Proud to be Albanian _____________________

                                  S Offline
                                  S Offline
                                  Steve Pullan
                                  wrote on last edited by
                                  #16

                                  albCode wrote:

                                  but u can get factorial until 33 otherwise 1000! gives u result 0 (zero)

                                  The problem is that you've defined f as an int. You'll need to use a different data type. ...Steve 1. quod erat demonstrandum 2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once :-) (Translation: I'll show you the way, but not write the code for you.)

                                  A 1 Reply Last reply
                                  0
                                  • S Steve Pullan

                                    nyc_user wrote:

                                    You need to use Stirling's formula,

                                    Yes but... this is an approximation (admittedly with an error approaching 1/n^2 for n=1000) and won't be good enough if the exact value is required. ...Steve 1. quod erat demonstrandum 2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once :-) (Translation: I'll show you the way, but not write the code for you.)

                                    S Offline
                                    S Offline
                                    spin vector
                                    wrote on last edited by
                                    #17

                                    That's virtually an absurd comment. The guy didn't give a type, so I might guess a double (or long would be better). Moreover, the leading coefficietly are easily googlable. If he wants all the digits down to the decimal point then that's a completely different problem. ;P

                                    S 1 Reply Last reply
                                    0
                                    • S spin vector

                                      That's virtually an absurd comment. The guy didn't give a type, so I might guess a double (or long would be better). Moreover, the leading coefficietly are easily googlable. If he wants all the digits down to the decimal point then that's a completely different problem. ;P

                                      S Offline
                                      S Offline
                                      Steve Pullan
                                      wrote on last edited by
                                      #18

                                      nyc_user wrote:

                                      That's virtually an absurd comment.

                                      Absurd? Hmmm....

                                      nyc_user wrote:

                                      The guy didn't give a type, so I might guess a double (or long would be better).

                                      The answer to 1000! is a whole number. So my comment still stands. Stirling's formula approximates the actual value (albeit a very good approximation) - there is some error involved.

                                      nyc_user wrote:

                                      If he wants all the digits down to the decimal point then that's a completely different problem.

                                      Yep I agree, however since he has not given us any more information on the assignment question, this discussion is academic. :) ...Steve 1. quod erat demonstrandum 2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once :-) (Translation: I'll show you the way, but not write the code for you.)

                                      S 1 Reply Last reply
                                      0
                                      • S Steve Pullan

                                        nyc_user wrote:

                                        That's virtually an absurd comment.

                                        Absurd? Hmmm....

                                        nyc_user wrote:

                                        The guy didn't give a type, so I might guess a double (or long would be better).

                                        The answer to 1000! is a whole number. So my comment still stands. Stirling's formula approximates the actual value (albeit a very good approximation) - there is some error involved.

                                        nyc_user wrote:

                                        If he wants all the digits down to the decimal point then that's a completely different problem.

                                        Yep I agree, however since he has not given us any more information on the assignment question, this discussion is academic. :) ...Steve 1. quod erat demonstrandum 2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once :-) (Translation: I'll show you the way, but not write the code for you.)

                                        S Offline
                                        S Offline
                                        Steini kallinn
                                        wrote on last edited by
                                        #19

                                        Acording to the answer generated from Maple 10, I don't think a small litle program is going to solve this...

                                        1000! =
                                        402387260077093773543702433923003985719374864210714632543799910429938512398
                                        629020592044208486969404800479988610197196058631666872994808558901323829669
                                        944590997424504087073759918823627727188732519779505950995276120874975462497
                                        043601418278094646496291056393887437886487337119181045825783647849977012476
                                        632889835955735432513185323958463075557409114262417474349347553428646576611
                                        667797396668820291207379143853719588249808126867838374559731746136085379534
                                        524221586593201928090878297308431392844403281231558611036976801357304216168
                                        747609675871348312025478589320767169132448426236131412508780208000261683151
                                        027341827977704784635868170164365024153691398281264810213092761244896359928
                                        705114964975419909342221566832572080821333186116811553615836546984046708975
                                        602900950537616475847728421889679646244945160765353408198901385442487984959
                                        953319101723355556602139450399736280750137837615307127761926849034352625200
                                        015888535147331611702103968175921510907788019393178114194545257223865541461
                                        062892187960223838971476088506276862967146674697562911234082439208160153780
                                        889893964518263243671616762179168909779911903754031274622289988005195444414
                                        282012187361745992642956581746628302955570299024324153181617210465832036786
                                        906117260158783520751516284225540265170483304226143974286933061690897968482
                                        590125458327168226458066526769958652682272807075781391858178889652208164348
                                        344825993266043367660176999612831860788386150279465955131156552036093988180
                                        612138558600301435694527224206344631797460594682573103790084024432438465657
                                        245014402821885252470935190620929023136493273497565513958720559654228749774
                                        011413346962715422845862377387538230483865688976461927383814900140767310446
                                        640259899490222221765904339901886018566526485061799702356193897017860040811
                                        889729918311021171229845901641921068884387121855646124960798722908519296819
                                        372388642614839657382291123125024186649353143970137428531926649875337218940
                                        694281434118520158014123344828015051399694290153483077644569099073152433278
                                        288269864602789864321139083506217095002597389863554277196742822248757586765
                                        752344220207573630569498825087968928162753848863396909959826280956121450994
                                        871701244516461260379029309120889086942028510640182154399457156805941872748
                                        998094254742173582401063677404595741785160829230135358081840096996372524230
                                        560855903700624271243416909004153690105933983835777939410970027753472000000
                                        000000000000000000000000000000000000000000000

                                        S 1 Reply Last reply
                                        0
                                        • S Steve Pullan

                                          albCode wrote:

                                          but u can get factorial until 33 otherwise 1000! gives u result 0 (zero)

                                          The problem is that you've defined f as an int. You'll need to use a different data type. ...Steve 1. quod erat demonstrandum 2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once :-) (Translation: I'll show you the way, but not write the code for you.)

                                          A Offline
                                          A Offline
                                          albCode
                                          wrote on last edited by
                                          #20

                                          "u have right" (maybe) _____________________ Proud to be Albanian _____________________

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups