factorial

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2007
Posts: 11
Reputation: jbstin is an unknown quantity at this point 
Solved Threads: 0
jbstin jbstin is offline Offline
Newbie Poster

factorial

 
0
  #1
Nov 17th, 2007
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?
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,440
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1473
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: factorial

 
0
  #2
Nov 17th, 2007
Already did -- see the previous thead you started this morning.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 2,462
Reputation: zandiago is on a distinguished road 
Solved Threads: 25
Featured Poster
zandiago's Avatar
zandiago zandiago is offline Offline
Nearly a Posting Maven

Re: factorial

 
0
  #3
Nov 17th, 2007
So...what/where is the method you've tried? Without providing you the answer...here is a basic outline:
  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:
  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.
I shot the sheriff....but I didn't shoot the deputy
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,440
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1473
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: factorial

 
0
  #4
Nov 17th, 2007
Originally Posted by zandiago View Post
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.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 47
Reputation: joshua.tilson is an unknown quantity at this point 
Solved Threads: 0
joshua.tilson's Avatar
joshua.tilson joshua.tilson is offline Offline
Light Poster

Re: factorial

 
0
  #5
Nov 17th, 2007
Yes, Please see this thread:
http://www.daniweb.com/forums/thread97147.html
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 2,462
Reputation: zandiago is on a distinguished road 
Solved Threads: 25
Featured Poster
zandiago's Avatar
zandiago zandiago is offline Offline
Nearly a Posting Maven

Re: factorial

 
0
  #6
Nov 17th, 2007
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.
I shot the sheriff....but I didn't shoot the deputy
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC