-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |