write a program in Java to find the sum of the given series S = 1 + (1*2) + 2 + (1*2*3) + 3 + ........ + 9 + (1*2*3* ........ 10)
Please tell fast
Answers
Answered by
1
public class SeriesSum {
static long factorial(long number) {
return (number = = 1) ? 1 : number * factorial(number - 1);
}
public static void main(String[ ] args) {
int S = 0;
for (int i = 1; i < 10; S += ++i + (factorial(i + 1)));
System.out.println("Sum of series - " + S);
}
}
Answered by
1
Answer:
Hope this would help you
Explanation:
class prog
{
public static void main(String args[])
{
int S=0, fact=1,c=1;
for(int i=1;i‹18=;i++)
{
if(i%2==0)
{ fact=fact*c;
S=S+fact;
}
else
S=S+(i-1);
c++;
}
}
}
Similar questions