Starting git repo for working on files
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
public class GeneralizedHarmonic
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
int n = Integer.parseInt(args[0]);
|
||||
int r = Integer.parseInt(args[1]);
|
||||
if (r >= 0 && n >= 0)
|
||||
{
|
||||
double h = 0;
|
||||
double breuk = 0;
|
||||
for (int i = 1; i <= n; i++ )
|
||||
{
|
||||
breuk = 1/(Math.pow(i,r));
|
||||
h += breuk;
|
||||
}
|
||||
System.out.println(h);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("Negative number in one of the arguments");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user