迭代算法 JAVA

来源:互联网 发布:宝宝在线起名软件 编辑:程序博客网 时间:2024/05/17 07:40

package arithmetic.dietai;

public class Iterative2 {

 /**
  * @param args
  */
 public static void main(String[] args) {
  System.out.println(getIterative2());
 }

 public static int getIterative2() {
  /*
   * n14 = n15/2,n13 = n14/2 ……
   *
   */
  int y = (int) java.lang.Math.pow(2, 20);
  int x = 0;
  for (int i = 0; i < 15; i++) {
   x = y / 2;
   y = x;
  }
  return x;
 }

原创粉丝点击