-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfor35.java
More file actions
27 lines (24 loc) · 556 Bytes
/
for35.java
File metadata and controls
27 lines (24 loc) · 556 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
package fori;
import java.util.Scanner;
public class for35 {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
int n = scanner.nextInt();
System.out.print("N:");
float a1 = 1F;
float a2 = 2F;
float a3 = 3F;
//
;
float ak;
for(int i = 4; i <= n; ++i)
{
ak = a3 + a2 - 2 * a1;
System.out.printf("A(%d)=%f \n",i,ak);
a1 = a2;
a2 = a3;
a3 = ak;
}
//
}
}