cout << "Please enter a positive integer: "; cin >> number; if (number < 0) cout << "That is not a positive integer.\n"; else cout << number << " factorial is: " << factorial(number) << endl; }
int factorial(int number) { int temp;
if(number <= 1) return 1;
temp = number * factorial(number - 1); return temp; }
http://www.bfoit.org/itp/Recursion.html
ReplyDeletehttp://www.cprogramming.com/tutorial/lesson16.html
would it be possible to use the recursive programming with action script
java script.
C++
C
PHP
are declared
ReplyDeletewill be using
http://www.cplusplus.com/doc/tutorial/variables/
Global variables: 전역변수
Local variables:지역변수
Instructions: 명령
declaring
a regular local variable.
Initialization of variable
변수를 사용하려면 상황에 맞게 이것을 맞추어 주어야 한다.
type identifier = initial_value;
**************************************************************
eg 1. int a = 0
what is the type of eg 1. ?
answer ( int )
what is the identifier of eg 1?
answer ( a )
what is the initial_value ?
answer ( 0 );
* declare an int variable called a initialiazed with a value of 0
**************************************************************************
constructor intitialization
done by enclosing the intial value b/w parentheses(());
type identifier (initial_value);
eg.
int a (0);
***********************example *************************************************
//initialization of variables
#include
using namespace std;
int main()
{
int a = 5; //initial value = 5;
int b(2); initial value is 2
int result; //initial value undetermined
a = a+3;
result = a- b;
cout << result;
return;
}
****************참고 Cout 에서 줄바꾸기 하기************************
********************************************************************
cout<<"Hello Word\n";
**********************************************************************
#include
using namespace std;
int main()
{
int n;
result = 1;
value = 3;
for (n =1; n<=value; n++)
{
result*=n;
}
cout<
//#include
#include
//#include
using namespace std;
int factorial(int);
void main(void) {
int number;
cout << "Please enter a positive integer: ";
cin >> number;
if (number < 0)
cout << "That is not a positive integer.\n";
else
cout << number << " factorial is: " << factorial(number) << endl;
}
int factorial(int number) {
int temp;
if(number <= 1) return 1;
temp = number * factorial(number - 1);
return temp;
}