मराठी

Write the program to find the sum of the following series: S = to n1a+2a2+3a3+.................. to n - Computer Applications

Advertisements
Advertisements

प्रश्न

Write the program to find the sum of the following series:

S = `1/a + 2/a^2 + 3/a^3 + .................. " to n"`

थोडक्यात उत्तर

उत्तर

import java.util.*;
public class Q3d
{public static void main(String args[])
{int a, n;
double term, sum = 0;
Scanner obj = new Scanner(System.in);
System.out.println("Enter the value of a");
a = obj.nextInt();
System.out.printIn("Enter the value of n");
n = obj.nextInt();
for (int i = 1; i <= n; i++)
{ term = i / Math.pow(a, i);
sum = sum + term;
} 
System.out.printIn("The sum of the series is " + sum);
}}
shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 1.09: Iterative Constructs in Java - EXERCISES [पृष्ठ १२४]

APPEARS IN

अविचल Computer Applications [English] Class 10 ICSE
पाठ 1.09 Iterative Constructs in Java
EXERCISES | Q VI. 3. (d) | पृष्ठ १२४
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×