示例#1
0
int main(){
	int a;
	scanf("%d", &a);
	printf("%d\n", factorial1(a));
	printf("%d\n", factorial2(a));

	return 0;
}
int main () {

int n=5;
int accumulator;

int  factorial1(n, accumulator) {
    if (n == 0) return accumulator;
    return factorial1(n - 1, n * accumulator);
  }

int factorial(n) {
    return factorial1(n, 1);
} 

n = factorial(n);

printf("Total is: %d\n",n);

}
示例#3
0
文件: factorial.c 项目: DonDiego/s2e
int main() {
    uint64_t x;
    uint64_t max = 10;

    //Make x symbolic
    s2e_make_symbolic(&x, sizeof(x), "x");

    uint64_t f1 = factorial1(x, max);
    uint64_t f2 = factorial2(x, max);

    //Check the equivalence of the two functions for each path
    s2e_assert(f1 == f2);

    //In case of success, terminate the state with the
    //appropriate message
    s2e_kill_state(0, "Success");
    return 0;
}
示例#4
0
int factorial1(int n){
	if(1<n) return n*factorial1(n-1);
	else return 1;
}