मराठी

Write a program to find the sum of the following series: S = 1 + to n32!+53!+74!+................to n - Computer Applications

Advertisements
Advertisements

प्रश्न

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

S = 1 + 32!+53!+74!+................to n

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

उत्तर

import java.util.*;
public class Q1a
{ public static void main(String args[])
{int a = 1, n, fact = 1; 
double term, sum = 0;
Scanner obj = new Scanner(System.in);
System.out.println("Enter the value of n");
n = obj.nextInt();
for (int i = 1; i <= n; i++)
{fact = 1;
for (int j = 1; j <= i; j++)
fact = fact * j;

term = (double) a / fact;
System.out.println(a + "/" + fact); // OPTIONAL PRINT
a = a + 2;
sum = sum + term;
}
System.out.printIn("Sum of the series = " + sum);
}}
shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 1.1: Nested Loop - EXERCISES [पृष्ठ १४५]

APPEARS IN

अविचल Computer Applications [English] Class 10 ICSE
पाठ 1.1 Nested Loop
EXERCISES | Q IV. 1. (a) | पृष्ठ १४५
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×
Our website is made possible by ad-free subscriptions or displaying online advertisements to our visitors.
If you don't like ads you can support us by buying an ad-free subscription or please consider supporting us by disabling your ad blocker. Thank you.