This repository has been archived by the owner on Oct 23, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4768 from abstatic/master
Merged by aniket965
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include<stdio.h> | ||
int main() | ||
{ | ||
int c, n; | ||
unsigned long fact = 1; | ||
printf("Enter a number to calculate its factorial\n"); | ||
scanf("%d", &n); | ||
for (c = n; c >= 1; c--) | ||
fact *= c; | ||
printf("Factorial of %d = %lu\n", n, fact); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class factorial | ||
{ | ||
void main() | ||
{ | ||
Scanner sc=new Scanner(System.in); | ||
int n=sc.nextInt(); | ||
int f=1; | ||
for (int i=2;i<=n;i++) | ||
{ | ||
f=f*i; | ||
} | ||
System.out.println(f); | ||
} | ||
} | ||
|