Computer Science, asked by yadavsudama77858, 7 months ago

Write a java (using for loop) program to print the sum of the series√a^n+ √a^n-1 + ..........+ √a^n

Answers

Answered by kiravaibhav1298
1

BRO YOUR CODE IS

static double sum(int x, int n)

{

double i, total = 1.0;

for (i = 1; i <= n; i++)

total = total +

(Math.pow(x, i) / i);

return total;

}

public static void main(String[] args)

{

int x = 2;

int n = 5;

System.out.printf("%.2f", sum(x, n));

}

}

Similar questions