// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.math.BigDecimal;
import java.math.RoundingMode;

public class MR {
    private static final BigDecimal C108 = new BigDecimal("108");
    private static final BigDecimal C815 = new BigDecimal("815");
    private static final BigDecimal C1500 = new BigDecimal("1500");
    public static BigDecimal f(BigDecimal y, BigDecimal z, int nd) {
        return C108.subtract(C815.subtract(C1500.divide(z, nd, RoundingMode.HALF_UP)).divide(y, nd, RoundingMode.HALF_UP));
    }
    public static void test(int nd, int n) {
        BigDecimal[] x = new BigDecimal[n + 1];
        x[0] = new BigDecimal("4");
        x[1] = new BigDecimal("4.25");
        for(int i = 2; i < n + 1; i++) {
            x[i] = f(x[i - 1], x[i - 2], nd);
        }
        for(int i = 0; i < n + 1; i++) {
            System.out.printf("%d|%s\n", i, x[i]);
        }
    }
    public static void main(String[] args) {
        test(20, 25);
        test(60, 50);
    }
}
