Skip to content

Commit

Permalink
Section7-3. 팩토리얼
Browse files Browse the repository at this point in the history
  • Loading branch information
gyuseon25 committed Jan 25, 2025
1 parent bdcc024 commit 6655bdd
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Section07/팩토리얼.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package 인프런.Section07;

import java.util.Scanner;

public class 팩토리얼 {
public void solution(int n) {
System.out.print(recursive(n));
}

public int recursive(int n) {
if(n == 1) {
return 1;
}
else {
return n*recursive(n-1);
}
}


public static void main(String[] args) {
팩토리얼 t = new 팩토리얼();
Scanner scanner = new Scanner(System.in);

int n = scanner.nextInt();

t.solution(n);
}
}

0 comments on commit 6655bdd

Please sign in to comment.