总结:与上一篇的不同是在main函数里。所以n的值是需要填写的。而不是未知值还是运用不灵活、

package com.c2;

//1+1/2+1/3+....+1/n的值
public class Dream {

	public static void main(String[] args) {

		double s = 0;

		for (int i = 1; i <= 10; i++) {
			s += (double) 1 / i;
		}
		System.out.println(s);
	}

}

  

相关文章:

  • 2021-06-18
  • 2022-12-23
  • 2022-02-11
  • 2022-12-23
  • 2022-12-23
  • 2021-09-02
  • 2021-10-28
  • 2021-05-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-15
相关资源
相似解决方案