Skip to content

Commit 6104848

Browse files
committed
Added Practice Code.
Signed-off-by: Someshdiwan <[email protected]>
1 parent 6a8b741 commit 6104848

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import java.util.stream.IntStream;
2+
3+
class Factorial {
4+
5+
static void printFactorial(int n) {
6+
long factorial = IntStream.rangeClosed(1, n)
7+
.reduce(1, (int a, int b) -> a * b);
8+
System.out.println("The factorial of the given number is: " + factorial);
9+
}
10+
11+
static void solve(int n) {
12+
printFactorial(n);
13+
}
14+
15+
public static void main(String[] args) {
16+
solve(6);
17+
}
18+
}

0 commit comments

Comments
 (0)