标题:分数

陌路散爱 提交于 2019-12-02 09:12:52
/*
 * 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));
    }
}

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!