6
My teacher is starting to pass functions, and asked us to do a factorial function of a number, but it always returns the wrong value and I do not know what happens.
Code:
int fatorial(int n) {
int ans = 1;
while(n>1){
ans*=n; n--; return ans;
}
}
That’s right, but I’m a fool, thank you.
– victor Carvalho