-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfor28.java
More file actions
32 lines (26 loc) · 669 Bytes
/
for28.java
File metadata and controls
32 lines (26 loc) · 669 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package fori;
import java.util.Scanner;
public class for28 {
public static void main(String[] args) {
float x;
Scanner scanner=new Scanner(System.in);
System.out.print("X:");
x = scanner.nextFloat();
int n;
System.out.print("N:");
n = scanner.nextInt();
float temp1 = 1F;
float temp2 = 1F;
float result = 1F;
float pow = 1F;
int i;
for (i = 1; i < n; ++i)
{
temp1 *= 2 * i - 3;
temp2 *= 2 * i;
pow *= (-1) * x;
result += temp1 * pow / temp2;
}
System.out.print(result+"\n");
}
}