标题:分数

/*
 * 1/1 + 1/2 + 1/4 + 1/8 + 1/16 + .... 
    每项是前一项的一半,如果一共有20项,
    求这个和是多少,结果用分数表示出来。
    数学得好呀
    (2^20-1)/2^19
 */
public class demo6 {
    public static void main(String[] args) {
        work();
    }

    public static void work() {
        System.out.println((int)Math.pow(2, 20)-1 +"/"+(int)Math.pow(2, 19));
    }
}

猜你喜欢

转载自www.cnblogs.com/hardhp74520/p/11740599.html
今日推荐