Skip to content

Commit 358052c

Browse files
committed
Added factorial in java and python in math folder
1 parent 565b5d3 commit 358052c

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed
File renamed without changes.

math/Java/factorial.class

928 Bytes
Binary file not shown.

math/Java/factorial.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//Atieve Wadhwa
2+
//Finding factorial of a number without recursion
3+
import java.util.*;
4+
5+
public class factorial
6+
{
7+
public static void main(String args[])
8+
{
9+
System.out.print("Enter Number: ");
10+
Scanner s = new Scanner(System.in);
11+
int n = s.nextInt();
12+
int ans = 1;
13+
while(n>1)
14+
{
15+
ans = n*ans;
16+
n = n-1;
17+
}
18+
19+
System.out.println("The factorial is: " + ans);
20+
s.close();
21+
}
22+
}

math/Python/factorial.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#Atieve Wadhwa
2+
#Finding factorial of a number without recursion
3+
4+
n = int(raw_input("Enter number to find factorial of: "))
5+
6+
ans = 1
7+
8+
while(n>1):
9+
ans = ans * n
10+
n = n-1
11+
12+
print("Factorial of given number is:")
13+
print(ans)

0 commit comments

Comments
 (0)