Answer:
Written in C
#include <stdio.h>
int myFactorial(int n){
int fact = 1;
for (int k = 1; k<=n;k++)
{
fact*=k;
}
return fact;
}
int main() {
int num;
printf("Number: ");
scanf("%d",&num);
if(num>=0) {
printf("%d",myFactorial(num));
}
return 0;
}
Explanation:
I've added the full program as an attachment where I used comments to explain some lines