1000!
-
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
-
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
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.
-
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.
In fact, n^n e^(-n) = exp( n ln(n) - n ), so calculate the argument and take the exponential (natural).
-
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
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 _____________________
-
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
-
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
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
-
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
-
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
-
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
-
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
-
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
-
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
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
-
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 _____________________
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
-
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.
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.)
-
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 _____________________
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 anint
. 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.) -
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.)
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
-
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
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.)
-
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.)
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 -
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 anint
. 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.)