您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ Factorial函数代码示例

51自学网 2021-06-01 20:45:36
  C++
这篇教程C++ Factorial函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中Factorial函数的典型用法代码示例。如果您正苦于以下问题:C++ Factorial函数的具体用法?C++ Factorial怎么用?C++ Factorial使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了Factorial函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: fastPermuteVectorOneLength

const VecStr fastPermuteVectorOneLength(std::string vec) {  VecStr ans;  int numOfPermutes = Factorial((int)vec.size());  ans.reserve(numOfPermutes);  do {    ans.push_back(vec);  } while (std::next_permutation(vec.begin(), vec.end()));  return ans;}
开发者ID:bailey-lab,项目名称:bibseq,代码行数:9,


示例2: main

int main() {    for (int i = 1; i <= 10; ++i)        std::cout << i << "!=" << Factorial(i) << std::endl;    /*std::cout << "Enter number: ";    std::cin >> n;    std::cout << "Result is ";    std::cout << Factorial(n) << std::endl;*/    return 0;}
开发者ID:IvanSmirnovRus,项目名称:code,代码行数:9,


示例3: Factorial

void Factorial(long n){  if (n == 0) {    res = 1;  } else {    Factorial(n-1);    res = n * res;  }}
开发者ID:rdspring1,项目名称:cs380c_pre_a4,代码行数:9,


示例4: Factorial

// Alright this is it --// Let's think about the "definition" of factorial for a second.// We said 3! = 1 * 2 * 3, which is equivalent to 3 * 2!.  We know 1! = 1, so by using// those simple facts we design our "factorial function" to mimic these properties.uint Factorial(uint num){    // Factorial of one is one, thus we'll return one    if(num == 1)        return 1;    else        return num * Factorial(num - 1); // Otherwise it's num * the factorial of (num - 1)}
开发者ID:jiangguang5201314,项目名称:ZNginx,代码行数:13,


示例5: msin

double msin(double x,double e) {  double j,a,b,k;  b= x ; j = 1 ;  	do 	{  		k = power(-1,j);  a  =k*power(x,2*j+1)/Factorial(2*j+1);	b =b + a;		j+=1;		}	while(a*k>e);return b;}
开发者ID:samhvw8,项目名称:cprogramingIntroduction,代码行数:10,


示例6: mex

double mex(double x,double e){ 	double j,a,b;	b= 1; j = 1 ; 	do 	{ 		a =power(x,j)/Factorial(j);b = b + a;		j+=1;		}	while(a>e);return b;}
开发者ID:samhvw8,项目名称:cprogramingIntroduction,代码行数:10,


示例7: TestFactorial

bool TestFactorial( ){    bool ok = true;    cout << "Testing Factorial" << endl;    TESTCHECK( Factorial( 12 ), 479001600, &ok );    TESTCHECK( Factorial( 20LL ), 2432902008176640000LL, &ok );    TESTCHECK( Factorial( 20. ), 2432902008176640000., &ok );    TESTCHECKF( Factorial( 50. ), 3.0414093203509456e64, &ok );    TESTCHECKFE( Factorial( 100. ), 9.3326e157, &ok, 1.e-5 );    TESTCHECK( BinomialCoefficient( 19, 7 ), 50388., &ok );    TESTCHECK( BinomialCoefficient( 20, 10 ), 184756., &ok );    if ( ok )        cout << "Factorial PASSED." << endl << endl;    else        cout << "Factorial FAILED." << endl << endl;    return ok;}
开发者ID:davidand36,项目名称:libEpsilonDelta,代码行数:20,


示例8: Factorial

/** Computes a factorial. */static INT Factorial(INT A){	if(A == 0)	{		return 1;	}	else	{		return A * Factorial(A - 1);	}}
开发者ID:LiuKeHua,项目名称:colorful-engine,代码行数:12,


示例9: Factorial

/** Computes a factorial. */static int32 Factorial(int32 A){	if(A == 0)	{		return 1;	}	else	{		return A * Factorial(A - 1);	}}
开发者ID:amyvmiwei,项目名称:UnrealEngine4,代码行数:12,


示例10: p

	Polynom Polynom::TimeShift(double shift) const	{		vector<double> v;		Polynom p(*this);		for (int i = 0; i <= Power(); ++i)		{			v.push_back(p(shift) / double(Factorial(i)));			p = p.Differenciate();		}		return Polynom(v);	}
开发者ID:aaalex88,项目名称:ACorePoly,代码行数:11,


示例11: Partition

void/* Partition(int N, double Rtheta, double IJ[N*2]) */Partition(int N, double Rtheta, double IJ[]){	int	level, var;	/*	double	I[STRLEN], J[STRLEN], factor, sum;*/        double	factor, sum;	for (var = 1; var <= N; var++)	{	    sum = 0.0;	    /* first term in hierarchy, occurs (N-1)! times */	    level = 1;	    sum += (Factorial(N - 1) * (d[level].m[var].X - Rtheta));	    /* last term in hierarchy, also occurs (N-1)! times */	    level = N;	    sum += (Factorial(N - 1) * ReturnDiff(level, var));	    for (level = 2; level < N; level++)    {		/* each difference occurs (j - 1)!(N - j)! times */		factor = 1.0 * Factorial(level - 1) * Factorial(N - level);		sum += factor * ReturnDiff(level, var);	    } /* for level ... 			    IJ[0][var-1] = I[var] = sum / Factorial(N);	    IJ[2][var-1] = J[var] = (d[1].m[var].X - Rtheta - I[var]);	      */	    IJ[var - 1] = sum / Factorial(N);	    IJ[N + var - 1] = (d[1].m[var].X - Rtheta - IJ[var - 1]);	} /* for var ... */	/*     Rprintf("/nvar/tI/tJ/tTot/n");	    	for (var = 1; var <= N; var++)	  {	    Rprintf("Var%d /t%4.3lf/t%4.3lf/t%4.3lf/n",	    var, I[var], J[var], I[var] + J[var]);	    }*/	} /* Partition() */
开发者ID:cran,项目名称:hier.part,代码行数:41,


示例12: Factorial

/* * Compute and return the factorial of a value, using a recursive algorithm. Zero factorial * will return 1. * @param value an unsigned integer containing the value for which the factorial will be computed * @return an unsigned integer containing the computed factorial of the value */unsigned int Factorial(unsigned int value){    if (value == 1 || value == 0)    {		return 1;    }		else	{		return (value * Factorial(value-1));	}	}
开发者ID:agonzales004,项目名称:CSCI-21-SPRING-2016,代码行数:18,


示例13: GeneratePermutedList

void GeneratePermutedList( int *list, int listLength, int permute ) {	for( int i = 0 ; i < listLength ; i++ ) {		list[i] = i;	}	// we can't calculate > 12 factorial, so we can't easily build a permuted list	if( listLength > 12 ) {		return;	}	// calculate listLength factorial	int		maxPermute = Factorial( listLength );	// recursively permute	PermuteList_r( list, listLength, permute, maxPermute );}
开发者ID:revelator,项目名称:Revelation,代码行数:13,


示例14: Factorial

int  Factorial(int n){	if(n == 0){		return 1;	} else {		return(n*Factorial(n-1));	}return 0;}
开发者ID:NerdMcDuck,项目名称:Computer-Architecture,代码行数:13,


示例15: test60Fact

void test60Fact() {    std::chrono::time_point<std::chrono::system_clock> start, end;    std::chrono::duration<double> elapsed_time;    start = std::chrono::system_clock::now();    BigInt fact60 = Factorial(60);    end = std::chrono::system_clock::now();    elapsed_time = end - start;#ifdef _PRINT_VALS    std::cout<< "fact60 took: " << elapsed_time.count() << " computing " << fact60 << std::endl;#endif    std::vector<limb_t> actual{18396530,1065373609,393476149,835766904,1949166040,1155626993,1901353954,234881024,0};    std::cout << "60! Correct? " << testEquals(fact60, actual) << std::endl;   }
开发者ID:Rosefield,项目名称:BigNum,代码行数:13,


示例16: TEST

// Tests factorial of negative numbers.TEST(FactorialTest, Negative) {  // This test is named "Negative", and belongs to the "FactorialTest"  // test case.  EXPECT_EQ(1, Factorial(-5));  EXPECT_EQ(1, Factorial(-1));  EXPECT_GT(Factorial(-10), 0);  // <TechnicalDetails>  //  // EXPECT_EQ(expected, actual) is the same as  //  //   EXPECT_TRUE((expected) == (actual))  //  // except that it will print both the expected value and the actual  // value when the assertion fails.  This is very helpful for  // debugging.  Therefore in this case EXPECT_EQ is preferred.  //  // On the other hand, EXPECT_TRUE accepts any Boolean expression,  // and is thus more general.  //  // </TechnicalDetails>}
开发者ID:admiralnlson,项目名称:Rigid3D,代码行数:23,


示例17: main

int main(){  int i;  int a[] = {1,2,3,4,5,6,7,8,9};  printf("Reverse to display an array:/n");  Reverse(a, 8);  i = HCF(1470, 693);  printf("Factorial 5! = %d/n", Factorial(5));  printf("Greates common devisor 1470 and 693 %d/n", i);  int n;  n = 3, i;  printf("%d/n", n);  return 0;}
开发者ID:khakimov,项目名称:secret-octo,代码行数:14,


示例18: main

void main(){	int f1 = 1, f2 = 1, n;	printf("%d/n", Square(2, 6));	printf("%d/n", Factorial(5));	printf("
C++ Fade函数代码示例
C++ Factor函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。