Please do question 19 part 3 series in blue j java
Attachments:
Answers
Answered by
1
Explanation:
import java.util.*;
import java.lang.Math;
public class Program
{
public static int factorial(int num){
int i = 1, fact = 1;
while(i <= num)
{
fact *= i;
i++;
}
return fact;
}
public static int fn(int x, int n){
int sum = 0, tmp = 1;
for(int i = 0; i <= n; i++){
sum += ((int)Math.pow(x, i)/factorial(tmp));
tmp += 2;
}
return sum;
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("enter the value for n: ");
int x = in.nextInt();
int n = in.nextInt();
System.out.println(fn(x, n));
}
}
Similar questions
Physics,
5 months ago
Physics,
5 months ago
Science,
5 months ago
Chemistry,
10 months ago
CBSE BOARD X,
1 year ago
Social Sciences,
1 year ago