// 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) using System; using java.math; namespace E { public static class NewerJavaEmulation { public static BigDecimal pow(this BigDecimal x, int n) { if (n == 0) { return new BigDecimal("1.0"); } else if (n == 1) { return x; } else { int nhalf = n / 2; return x.pow(nhalf).multiply(x.pow(n - nhalf)); } } } public class Program { public static void Main(string[] args) { BigDecimal x = new BigDecimal("2.0"); for (int i = 0; i < 32; i++) { Console.WriteLine(x.pow(i)); } } } }