source file name: SumSeries1.java

class A

{

int n;

public A(int m)

{

n=m;

}

public void sum()

{

float sum=1;

float i=n;

while(i>0)

{

sum=sum+((i-1)/i);

i--;

}

System.out.println(sum);

}

}

class SumSeries1

{

public static void main(String args[])

int i;

i=Integer.parseInt(args[0]);

A ob=new A(i);

System.out.println("Sum of series upto "+i);

ob.sum();

}

}


output:

D:\JavaPrograms\Constructors>javac SumSeries1.java

D:\JavaPrograms\Constructors>java SumSeries1 12
Sum of series upto 12
9.8967905