View Code of Problem 610

import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in =new Scanner(System.in);
		while(in.hasNext()) {
			int n  =in.nextInt();
			System.out.println(a(n));
		}
	}
	public static int a(int n) {
		if(n==1) {
			return 1;
		}else if(n==2) {
			return 2;
		}else {
			return a(n-1)+(n*n-n)/2*a(n-2);
		}
	}
}

Double click to view unformatted code.


Back to problem 610