For Better Performance Please Use Chrome or Firefox Web Browser

22-3

#include<iostream.h>

long myFaktoriyel(long n);
long myFaktoriyelBazgashti(long n);

void main ()
{
	long f, f2;
	f = myFaktoriyel(4);
	f2 = myFaktoriyelBazgashti(4);
	cout << "4! = " << f  << " = " << f2 << endl;
}

long myFaktoriyel(long n)
{
	long fact = 1;
	while (n) {
		fact *= n;
		n--;
	}
	return fact;
}


long myFaktoriyelBazgashti(long n)
{
	if (n<2)
		return 1;
	return n * myFaktoriyelBazgashti(n-1);
}

تحت نظارت وف ایرانی