Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ab03f0f

Browse files
solve the problem
1 parent 4179c85 commit ab03f0f

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

‎factorial/factorial.java‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import java.io.*;
2+
import java.util.*;
3+
import java.text.*;
4+
import java.math.*;
5+
import java.util.regex.*;
6+
7+
public class Solution {
8+
9+
static int factorial(int n) {
10+
if(n <= 1) {
11+
return n;
12+
}
13+
return n * factorial(n - 1);
14+
}
15+
16+
public static void main(String[] args) {
17+
Scanner in = new Scanner(System.in);
18+
int n = in.nextInt();
19+
int result = factorial(n);
20+
System.out.println(result);
21+
}
22+
}

‎factorial/from here‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://www.hackerrank.com/challenges/30-recursion/problem

‎factorial/problem.png‎

89.8 KB
Loading[フレーム]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /