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