Skip to content

Commit

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

import java.util.Scanner;

public class 재귀함수_이진수 {
public void solution(int n) {
recursive(n);
}

public void recursive(int n) {
if(n == 1) {
System.out.print(n);
return;
}
else {
recursive(n/2);
System.out.print(n%2);
}
}


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 bdcc024

Please sign in to comment.