package 練習; import java.util.Date; import java.util.Scanner; public class main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); double n=sc.nextDouble(); long exec_time=new Date().getTime(); double prd=0; double e_prd=0; double e_cost=1; for(double i=2;i<=n;i++){; if(i>2) e_prd=prd/((i-1)*(i-2));//積の平均 e_cost+=2/i+e_prd*(i-2)/i; prd+=(i-1)*i*i;//1~iまでの2数の積の和 } System.out.println(e_cost); System.err.println(new Date().getTime()-exec_time+"ms"); } }