Comments

Actually, you can think there are 1 * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 states.But as you see, if we have 8 ,we dont need 2、4 any more. If we have 9, we dont need 3 anymore. So 5 * 7 * 8 * 9 = 2520.

Can you tell me how to use bruteforce to calculate "D(N) which size might be of the order of 8 * 10^8 " please? Thanks.