C language calculate the factorial function method

C language calculate the factorial function method

1:
long N(int x){
	int i = 1;
	long s = 1;

	for(i = 1; i <= x; i++) {
		s = s * i;
	}

	return s;
}

2:
long N(int x)
{
    if (x == 1) {
        return x;
    } else {
        return x * N(x - 1);
    }
}

Comments

Popular posts from this blog

Python Receiving and parse JSON Data via UDP protocol

ubus lua client method and event registration code demo/example