i have this assignment to compute the factorial of an integer of any length. I have done it using array of char and then overloading the * operator accordingly. It works fine but i wanted to know if there were other efficient algorithms for counting factorials of any length. Give me some links if u find some. My search in google did not return anything exciting. If urs does then plz give me the links.
Asif_NSU
25
Posting Whiz
Recommended Answers
Jump to PostCan u please, post ur solution
If u can`t post the soln. then can u please explain how to find the factorial of a number of any length.
Jump to PostThat's the problem when you pull code from some website or book and submit it as your own... You learn nothing from it.
Learn to make your own code, learn to understand the code of others.
Jump to PostHere is the way I figured it out:
Let's say 5! = 1 * 2 * 3 * 4 * 5
the 1 drops out then 5! = 2 * 3 * 4 * 5
apply the log operator log(5!) = log(2) + log(3) + log(4) + log(5)…
Jump to Posthow to define a class which can "hold an integer of any length". my problem is that i am unable to define an integer of any length".
Jump to PostNO-ONE has used the simple loop method! im not sure how it compares but the posted snippet a while back certainly seems overkill for a simple factorial function.
Heres my code:
long Factorial (int base) // Factorial(4) = 4! { long result = (long)base; for(int i = …
All 18 Replies
Asif_NSU
25
Posting Whiz
varunrathi
0
Light Poster
jwenting
1,889
duckman
Team Colleague
Asif_NSU
25
Posting Whiz
Asif_NSU
25
Posting Whiz
vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague
varunrathi
0
Light Poster
1o0oBhP
4
Posting Pro in Training
BountyX
7
Posting Whiz in Training
vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague
1o0oBhP
4
Posting Pro in Training
vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague
alc6379
120
Cookie... That's it
Team Colleague
Asif_NSU
25
Posting Whiz
1o0oBhP
4
Posting Pro in Training
varunrathi
0
Light Poster
Dave Sinkula
2,398
long time no c
Team Colleague
roxanne_gem07
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.