WAP i java to print the sum of the series s={(1^2)/a}+{(3^2)/a}+{(5^2)/a}................n terms
Answers
Answered by
1
Answer:
Program to find the sum of the series (1/a + 2/a^2 + 3/a^3 + … + n/a^n)
Given two integers
a and
n. The task is to find the sum of the series 1/a + 2/a2 + 3/a3 + … + n/an.
Examples:
Input: a = 3, n = 3
Output: 0.6666667
The series is 1/3 + 1/9 + 1/27 which is
equal to 0.6666667
Input: a = 5, n = 4
Output: 0.31039998
Recommended: Please try your approach on {IDE} first, before moving on to the solution.
Approach: Run a loop from 1 to n and get the
i-th term of the series by calculating term = (i / ai). Sum all the generated terms
Similar questions
Math,
3 months ago
Social Sciences,
3 months ago
Physics,
7 months ago
Social Sciences,
7 months ago