We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6a8b741 commit 6104848Copy full SHA for 6104848
JAVA8/StreamsInJAVA/src/Factorial.java
@@ -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