문서 색인

2. 코드

package Test;

public class JumpCase {
	public static void main(String[] args) {
		JumpCase jc = new JumpCase();
		for ( int inx=0; inx<10; inx++ ) {
			System.out.println((inx+1) + " = " + jc.jumpCase(inx+1));
		}
	}

	private int jumpCase(int i) {
		int sum = 0;
		
		if ( i == 1 || i == 2 ) {
			sum = i;
		} else {
			for (int inx = 3; inx <= i; inx++) {
				sum = jumpCase(inx-2)+jumpCase(inx-1);
			}
		}
		return sum;
	}
}