输入正整数n,求1/2+2/3+...+(n-1)/n用python到底怎么写
来源:2-1 无参无返回值方法
孤初
2020-05-26 18:42:37
package com.c2;
//1+1/2+1/3+....+1/n的值
public class Dream { public static void count(int n)
{ double s = 0; for (int i = 1; i <= n; i++) { s += (double) 1 / i; }
System.out.println(s); }
public static void main(String[] args) { count(2); }}
1回答
好帮手慕阿慧
2020-05-26
同学你好,这里是学习Java的,建议同学到对应的地方询问Python的问题。祝学习愉快~
相似问题