题解 | #牛牛学数列2#
牛牛学数列2
http://www.nowcoder.com/practice/fc72951f52984f3abd286d82eeffacba
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); double s=0.0,sum=0.0; for(int i=1;i<=n;i++) { s=1.0/i; sum=sum+s; } System.out.printf("%.6f",sum); } }