Skip to content

Commit

Permalink
Section7-1. 재귀함수
Browse files Browse the repository at this point in the history
  • Loading branch information
gyuseon25 committed Jan 25, 2025
1 parent ebe322f commit 012d954
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Section07/재귀함수.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package 인프런.Section07;

import java.util.Scanner;

public class 재귀함수 {

public void solution(int n) {
recursive(n);
}

public void recursive(int n) {
if(n == 0)
return;
else {
recursive(n-1);
System.out.print(n + " ");
}
}


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 012d954

Please sign in to comment.