package com.company; import java.text.DecimalFormat; import java.util.Scanner; public class Main { public static void main(String[] args) { // write your code here Scanner sc=new Scanner(System.in); int N=sc.nextInt(); double sum=0; DecimalFormat df=new DecimalFormat("0.000000"); for(int i=N;i>0;i--){ double nd=Double.valueOf(i); sum=sum+1/nd; } System.out.println("sum = "+df.format(sum)); } }