My teacher is starting to go through 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;
}
}