forked from PraveenMohan13/BASIC-50
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFactorial
More file actions
30 lines (30 loc) · 663 Bytes
/
Factorial
File metadata and controls
30 lines (30 loc) · 663 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>
int main() {
int n=5,ans=1;
for(int i=1;i<=n;i++)
ans=ans*i;
printf("%d",ans);
}
-------------------------------------------------------------------------------------------------------------------------------------------------
#include <stdio.h>
int main() {
int n=5,ans=1;
while(n>0)
{
ans=ans*n;
n--;
}
printf("%d",ans);
}
-------------------------------------------------------------------------------------------------------------------------------------------------
#include<stdio.h>
int main()
{
int n,ans=1,i=1;
scanf("%d",&n);
while(i<=n){
ans=ans*i;
i++;
}
printf("%d",ans);
}