-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRecur.java
More file actions
30 lines (24 loc) · 468 Bytes
/
Recur.java
File metadata and controls
30 lines (24 loc) · 468 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package chap05_2;
import java.util.Scanner;
public class Recur {
static void recur(int n) {
if (n > 0) {
recur(n - 1);
System.out.println(n);
recur(n - 2);
}
}
static void recur2(int n) {
if (n > 0) {
recur2(n - 2);
System.out.println(n);
recur2(n - 1);
}
}
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
System.out.print("Á¤¼ö¸¦ ÀÔ·ÂÇϼ¼¿ä.£º");
int x = stdIn.nextInt();
recur2(x);
}
}