944,079 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 996
  • C++ RSS
Nov 17th, 2007
0

factorial

Expand Post »
please help me to find how to find the factorial of a number in a easy way?
the methods i have seen are difficult to me .can any one heelp me to solve the problem?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jbstin is offline Offline
11 posts
since Nov 2007
Nov 17th, 2007
0

Re: factorial

Already did -- see the previous thead you started this morning.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,957 posts
since Aug 2005
Nov 17th, 2007
0

Re: factorial

So...what/where is the method you've tried? Without providing you the answer...here is a basic outline:
C++ Syntax (Toggle Plain Text)
  1. #include <iostream>
  2. #include <cctype>
  3. #include <iomanip>
  4. #include <cmath>
  5. #include <fstream>
  6. #include <string>
  7.  
  8.  
  9. using namespace std;
  10.  
  11. int main(void)
  12. {
  13. int num;//number to get it's factorial
  14.  
  15. cout << "Please enter a positive number: ";
  16. cin >> num;//user enters number
  17. if (num < 0)
  18. {
  19. cout << "That is not a positive number.\n";
  20. }
  21. else
  22. {
  23. cout << num << " factorial is: " << factorial(num) << endl;
  24. }
The above isn't complete nor tested. Also, in the future, before posting, search the forums to see if someone else had the same problem/assignment. We are willing to help, but we don't want to waste time doing the same thing over and over again...In the factorial function, you could try something like this:
C++ Syntax (Toggle Plain Text)
  1. int factorial(int )
  2. {
  3. int temp;
  4. if(num <= 1) return 1;
  5. //figure out the simple calculaltion
  6. return temp;
  7. }//end for factorial
hope this helps.
Featured Poster
Reputation Points: 129
Solved Threads: 26
Nearly a Posting Maven
zandiago is offline Offline
2,463 posts
since Jun 2007
Nov 17th, 2007
0

Re: factorial

Click to Expand / Collapse  Quote originally posted by zandiago ...
So...what/where is the method you've tried? Without providing you the answer...here is a basic outline:
I guess you need to learn to read too. Problem already solved in another thread.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,957 posts
since Aug 2005
Nov 17th, 2007
0

Re: factorial

Yes, Please see this thread:
http://www.daniweb.com/forums/thread97147.html
Reputation Points: 13
Solved Threads: 0
Light Poster
joshua.tilson is offline Offline
47 posts
since Nov 2007
Nov 17th, 2007
0

Re: factorial

ok ok...totally missed that one...i didn't see another thread started by jbstin...the title of the threads were different...so i just went right in...my eyes need tested anyways...and AD...i'm not in kindergarden yet...so i can't read too well.
Last edited by zandiago; Nov 17th, 2007 at 10:03 am.
Featured Poster
Reputation Points: 129
Solved Threads: 26
Nearly a Posting Maven
zandiago is offline Offline
2,463 posts
since Jun 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: C++ copy file
Next Thread in C++ Forum Timeline: call and sms blocker





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC