Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- It calculates the factorial of a given natural number n.
- */
- #include <stdio.h>
- int main(){
- int n, w = 1;
- printf("Enter n: ");
- scanf("%d", &n);
- while(n > 0){
- w = w*n;
- n = n - 1;
- }
- printf("%d\n", w);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement